CakeAddresses/config/Migrations/20251121020203_InitialAddre...

46 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2025-11-22 05:26:00 +00:00
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class InitialAddressesDynamicForeignKey extends AbstractMigration
{
/**
* Up Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-up-method
* @return void
*/
public function up(): void
{
$this->table('addresses')
->addColumn('foreign_key', 'string', [
'limit' => 45,
'null' => true,
'default' => null,
])
->addColumn('model', 'string', [
'limit' => 255,
'null' => true,
'default' => null,
])
->update();
}
/**
* Down Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-down-method
* @return void
*/
public function down(): void
{
$this->table('addresses')
->removeColumn('foreign_key')
->removeColumn('model')
->save();
}
}