47 lines
1.8 KiB
PHP
47 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 20260906040200_theme_file_versions.php
|
||
|
|
*
|
||
|
|
* Author: Funky Waddle
|
||
|
|
* Date: 2026-09-06
|
||
|
|
*
|
||
|
|
* Purpose: Migration that creates the `theme_file_versions` table backing
|
||
|
|
* "Theme Editor File Versioning" (`themes_architecture` in APP.yaml): every
|
||
|
|
* save made through the in-place Theme Editor stores the prior file content
|
||
|
|
* here first, so an accidental bad edit can be reverted without needing the
|
||
|
|
* full Site Restore feature.
|
||
|
|
*/
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use Phinx\Migration\AbstractMigration;
|
||
|
|
|
||
|
|
final class ThemeFileVersions 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('theme_file_versions');
|
||
|
|
$table->addColumn('theme_type', 'string', ['limit' => 20, 'null' => false, 'comment' => "'frontend' or 'admin'"])
|
||
|
|
->addColumn('theme_name', 'string', ['limit' => 255, 'null' => false])
|
||
|
|
->addColumn('file_path', 'string', ['limit' => 500, 'null' => false, 'comment' => 'path relative to the theme root'])
|
||
|
|
->addColumn('content', 'text', ['null' => false, 'comment' => 'file content as it was BEFORE the save that created this version'])
|
||
|
|
->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
||
|
|
->addColumn('created_by', 'integer', ['null' => true])
|
||
|
|
->addForeignKey('created_by', 'users', 'id')
|
||
|
|
->addIndex(['theme_type', 'theme_name', 'file_path'])
|
||
|
|
->create();
|
||
|
|
}
|
||
|
|
}
|