add skill and position
This commit is contained in:
33
console/migrations/m181012_082916_create_position_table.php
Normal file
33
console/migrations/m181012_082916_create_position_table.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `position`.
|
||||
*/
|
||||
class m181012_082916_create_position_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
$this->createTable('position', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string(100)->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('position');
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles adding position_id to table `user_card`.
|
||||
*/
|
||||
class m181012_093626_add_position_id_column_to_user_card_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('user_card', 'position_id', $this->integer(11));
|
||||
$this->addForeignKey(
|
||||
'user_card_ibfk_position',
|
||||
'user_card',
|
||||
'position_id',
|
||||
'position',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('user_card_ibfk_position', 'user_card');
|
||||
|
||||
$this->dropColumn('project', 'company_id');
|
||||
}
|
||||
}
|
62
console/migrations/m181012_102422_create_skill_table.php
Normal file
62
console/migrations/m181012_102422_create_skill_table.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `skill`.
|
||||
*/
|
||||
class m181012_102422_create_skill_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
$this->createTable('skill', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string(100)->notNull(),
|
||||
], $tableOptions);
|
||||
|
||||
$this->createTable('card_skill', [
|
||||
'id' => $this->primaryKey(),
|
||||
'card_id' => $this->integer(11)->notNull(),
|
||||
'skill_id' => $this->integer(11)->notNull(),
|
||||
], $tableOptions);
|
||||
|
||||
$this->addForeignKey(
|
||||
'card_skill_ibfk_user_card',
|
||||
'card_skill',
|
||||
'card_id',
|
||||
'user_card',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
|
||||
$this->addForeignKey(
|
||||
'card_skill_ibfk_skill',
|
||||
'card_skill',
|
||||
'skill_id',
|
||||
'skill',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
|
||||
$this->dropTable('card_skill');
|
||||
$this->dropTable('skill');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user