SiteWeaver_CMS/database/migrations/20260905231800_user_email_verification.php

41 lines
1.2 KiB
PHP

<?php
/**
* 20260905231800_user_email_verification.php
*
* Author: Funky Waddle
* Date: 2026-09-05
*
* Purpose: Migration that creates the `user_email_verification` table storing email verification tokens.
*/
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class UserEmailVerification extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$table = $this->table('user_email_verification');
$table->addColumn('user_id', 'integer', ['null'=> false])
->addColumn('token', 'string', ['limit' => 42, 'null' => false])
->addColumn('created_at', 'datetime', ['null' => false, 'default'=>"CURRENT_TIMESTAMP"])
->addColumn('expires_at', 'datetime', ['null' => false])
->addForeignKey('user_id', 'users', 'id')
->addIndex('token', ["unique" => true])
->create();
}
}