add task module
This commit is contained in:
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table
|
||||
*/
|
||||
class m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->dropForeignKey('project_user_ibfk_user_card', 'project_user');
|
||||
$this->dropColumn('project_user', 'card_id');
|
||||
$this->addColumn('project_user', 'user_id', $this->integer(11)->notNull());
|
||||
$this->addForeignKey('user_project_user', 'project_user', 'user_id', 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('user_project_user', 'project_user');
|
||||
$this->dropColumn('project_user', 'user_id');
|
||||
$this->addColumn('project_user', 'card_id', $this->integer(11)->notNull());
|
||||
$this->addForeignKey(
|
||||
'project_user_ibfk_user_card',
|
||||
'project_user',
|
||||
'card_id',
|
||||
'user_card',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
43
console/migrations/m211123_083938_create_task_table.php
Normal file
43
console/migrations/m211123_083938_create_task_table.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%task}}`.
|
||||
*/
|
||||
class m211123_083938_create_task_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%task}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'project_id' => $this->integer(11)->notNull(),
|
||||
'title' => $this->string(),
|
||||
'status' => $this->integer(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
'project_user_id' => $this->integer(),
|
||||
'user_id' => $this->integer(),
|
||||
'description' => $this->string(500),
|
||||
]);
|
||||
$this->addForeignKey('task_project', 'task',
|
||||
'project_id', 'project', 'id');
|
||||
$this->addForeignKey('task_project_user', 'task',
|
||||
'project_user_id', 'project_user', 'id');
|
||||
$this->addForeignKey('task_user', 'task', 'user_id', 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('task_project', 'task');
|
||||
$this->dropForeignKey('task_project_user', 'task');
|
||||
$this->dropForeignKey('task_user', 'task');
|
||||
$this->dropTable('{{%task}}');
|
||||
}
|
||||
}
|
35
console/migrations/m211123_085751_create_task_user_table.php
Normal file
35
console/migrations/m211123_085751_create_task_user_table.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%task_user}}`.
|
||||
*/
|
||||
class m211123_085751_create_task_user_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%task_user}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'task_id' => $this->integer(),
|
||||
'project_user_id' => $this->integer(),
|
||||
]);
|
||||
$this->addForeignKey('task_task_user', 'task_user',
|
||||
'task_id', 'task', 'id');
|
||||
$this->addForeignKey('project_user_task_user', 'task_user',
|
||||
'project_user_id', 'project_user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('task_task_user', 'task_user');
|
||||
$this->dropForeignKey('project_user_task_user', 'task_user');
|
||||
$this->dropTable('{{%task_user}}');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user