SiteWeaver_CMS/database/migrations/20260906020800_blog_post_versions.php

47 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* 20260906020800_blog_post_versions.php
*
* Author: Funky Waddle
* Date: 2026-09-06
*
* Purpose: Migration that creates the `blog_post_versions` table storing versioned content revisions of blog posts.
*/
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class BlogPostVersions 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_post_versions');
$table->addColumn('post_id', 'integer', ['null'=> false])
->addColumn('version_number', 'integer', ['null' => false])
->addColumn('locale', 'string', ['limit' => 3, 'null' => false])
->addColumn('extract', 'text', ['null' => true])
->addColumn('content', 'text', ['null' => false])
->addColumn('meta_json', 'text', ['null' => true])
->addColumn('created_at', 'datetime', ['null' => false, 'default'=>"CURRENT_TIMESTAMP"])
->addColumn('created_by', 'integer', ['null' => true])
->addColumn('is_published', 'boolean', ['null' => false, 'default' => false])
->addColumn('published_at', 'datetime', ['null' => true])
->addForeignKey('post_id', 'blog_posts', 'id')
->addForeignKey('created_by', 'users','id')
->create();
}
}