changes in manager and manager_employee, replaced user_id to card_id

This commit is contained in:
iIronside
2021-12-23 11:28:27 +03:00
parent ce25dc44ea
commit ac4e5d62ec
22 changed files with 2570 additions and 71 deletions

View File

@ -0,0 +1,50 @@
<?php
use yii\db\Migration;
/**
* Class m211222_083459_change_foreign_key_in_manager_from_user_id_to_user_card_id
*/
class m211222_083459_change_foreign_key_in_manager_from_user_id_to_user_card_id extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->dropForeignKey('manager_user', 'manager');
$this->dropColumn('manager', 'user_id');
$this->addColumn('manager', 'user_card_id', $this->integer(11));
$this->addForeignKey('manager_user_card', 'manager', 'user_card_id',
'user_card', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('manager_user_card', 'manager');
$this->dropColumn('manager', 'user_card_id');
$this->addColumn('manager', 'user_id', $this->integer(11));
$this->addForeignKey('manager_user', 'manager', 'user_id', 'user', 'id');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m211222_083459_change_foreign_key_in_manager_from_user_id_to_user_card_id cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,34 @@
<?php
use yii\db\Migration;
/**
* Class m211222_083709_change_foreign_key_in_manager_employee_from_user_id_to_user_card_id
*/
class m211222_083709_change_foreign_key_in_manager_employee_from_user_id_to_user_card_id extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->dropForeignKey('employee_user', 'manager_employee');
$this->dropColumn('manager_employee', 'employee_id');
$this->addColumn('manager_employee', 'user_card_id', $this->integer(11));
$this->addForeignKey('manager_employee_user_card', 'manager_employee', 'user_card_id',
'user_card', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('manager_employee_user_card', 'manager_employee');
$this->dropColumn('manager_employee', 'user_card_id');
$this->addColumn('manager_employee', 'employee_id', $this->integer(11));
$this->addForeignKey('employee_user', 'manager_employee', 'employee_id', 'user', 'id');
}
}