46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
|
|
<?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();
|
||
|
|
}
|
||
|
|
}
|