Update phone to use name instead of number and update sended to use phone id instead of origin

This commit is contained in:
osaajani 2020-03-31 01:19:21 +02:00
parent 62c7f69395
commit d5be760843
12 changed files with 91 additions and 93 deletions

View file

@ -0,0 +1,29 @@
<?php
use Phinx\Migration\AbstractMigration;
class UpdatePhoneToReplaceNumber extends AbstractMigration
{
public function change()
{
$table = $this->table('phone');
$table->removeColumn('number');
$table->addColumn('name', 'string', ['null' => false, 'limit' => 150]);
$table->addIndex('name', ['unique' => true]);
$table->update();
$table = $this->table('sended');
$table->removeColumn('origin');
$table->addColumn('id_phone', 'integer', ['null' => true]);
$table->addForeignKey('id_phone', 'phone', 'id', ['delete' => 'SET_NULL', 'update' => 'CASCADE']);
$table->update();
$table = $this->table('received');
$table->removeColumn('destination');
$table->addColumn('id_phone', 'integer', ['null' => true]);
$table->addForeignKey('id_phone', 'phone', 'id', ['delete' => 'SET_NULL', 'update' => 'CASCADE']);
$table->update();
}
}