dynamic foriegn key on addresses

This commit is contained in:
2025-11-21 21:26:00 -08:00
parent df190953f4
commit 3360ef8f7b
3 changed files with 225 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?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();
}
}