Migration foreign keys
This commit is contained in:
@ -34,13 +34,21 @@ class CreateValues extends Phinx\Migration\AbstractMigration
|
||||
'signed' => false,
|
||||
'after' => 'value',
|
||||
])
|
||||
->addIndex(['currency_id'], [
|
||||
/*->addIndex(['currency_id'], [
|
||||
'name' => 'currency_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['base_id'], [
|
||||
'name' => 'base_id',
|
||||
'unique' => false,
|
||||
])*/
|
||||
->addForeignKey(['currency_id'], 'currencies', ['id'], [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'CASCADE'
|
||||
])
|
||||
->addForeignKey(['base_id'], 'currencies', ['id'], [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'CASCADE'
|
||||
])
|
||||
->create();
|
||||
/*$this->table('currencies', [
|
||||
|
@ -53,9 +53,13 @@ final class CreateSources extends AbstractMigration
|
||||
'encoding' => 'utf8mb4',
|
||||
'after' => 'url',
|
||||
])
|
||||
->addIndex(['currency_id'], [
|
||||
/*->addIndex(['currency_id'], [
|
||||
'name' => 'currency_id',
|
||||
'unique' => false,
|
||||
])*/
|
||||
->addForeignKey(['currency_id'], 'currencies', ['id'], [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'CASCADE'
|
||||
])
|
||||
->create();
|
||||
}
|
||||
|
59
db/migrations/20210414015145_create_aliases.php
Normal file
59
db/migrations/20210414015145_create_aliases.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateAliases 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
|
||||
{
|
||||
$this->table('aliases', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => '10',
|
||||
'signed' => false,
|
||||
'identity' => 'enable',
|
||||
])
|
||||
->addColumn('currency_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => '10',
|
||||
'signed' => false,
|
||||
'after' => 'id',
|
||||
])
|
||||
->addColumn('alias', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'encoding' => 'utf8mb4',
|
||||
'after' => 'currency_id',
|
||||
])
|
||||
/*->addIndex(['currency_id'], [
|
||||
'name' => 'currency_id',
|
||||
'unique' => false,
|
||||
])*/
|
||||
->addForeignKey(['currency_id'], 'currencies', ['id'], [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'CASCADE'
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user