45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 20260906021300_blog_comments.php
|
||
|
|
*
|
||
|
|
* Author: Funky Waddle
|
||
|
|
* Date: 2026-09-06
|
||
|
|
*
|
||
|
|
* Purpose: Migration that creates the `blog_comments` table storing comments on blog posts.
|
||
|
|
*/
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use Phinx\Migration\AbstractMigration;
|
||
|
|
|
||
|
|
final class BlogComments 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('blog_comments');
|
||
|
|
$table->addColumn('post_id', 'integer', ['null'=> false])
|
||
|
|
->addColumn('user_id', 'integer', ['null' => false])
|
||
|
|
->addColumn('content', 'text', ['null' => false])
|
||
|
|
->addColumn('likely_spam', 'boolean', ['null' => false])
|
||
|
|
->addColumn('created_at', 'datetime', ['null' => false, 'default'=>"CURRENT_TIMESTAMP"])
|
||
|
|
->addColumn('updated_at', 'datetime', ['null' => true])
|
||
|
|
->addColumn('updated_by', 'integer', ['null' => true])
|
||
|
|
->addForeignKey('post_id', 'blog_posts', 'id')
|
||
|
|
->addForeignKey('user_id', 'users', 'id')
|
||
|
|
->addForeignKey('updated_by', 'users','id')
|
||
|
|
->create();
|
||
|
|
}
|
||
|
|
}
|