43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 20260906040100_plugin_migrations.php
|
||
|
|
*
|
||
|
|
* Author: Funky Waddle
|
||
|
|
* Date: 2026-09-06
|
||
|
|
*
|
||
|
|
* Purpose: Migration that creates the `plugin_migrations` table, used by the
|
||
|
|
* custom `PluginMigrationRunner` (`plugins_architecture` -> "Modular DB
|
||
|
|
* Migrations" in APP.yaml) to track which of a plugin's own migration files
|
||
|
|
* have already been run, so install/uninstall can run/reverse only the
|
||
|
|
* migrations belonging to that plugin's `migrations/` folder.
|
||
|
|
*/
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use Phinx\Migration\AbstractMigration;
|
||
|
|
|
||
|
|
final class PluginMigrations 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('plugin_migrations');
|
||
|
|
$table->addColumn('plugin_name', 'string', ['limit' => 255, 'null' => false])
|
||
|
|
->addColumn('migration', 'string', ['limit' => 255, 'null' => false])
|
||
|
|
->addColumn('applied_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
||
|
|
->addIndex(['plugin_name', 'migration'], ['unique' => true])
|
||
|
|
->create();
|
||
|
|
}
|
||
|
|
}
|