add company
This commit is contained in:
44
console/migrations/m181011_140628_create_company_table.php
Normal file
44
console/migrations/m181011_140628_create_company_table.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `company`.
|
||||
*/
|
||||
class m181011_140628_create_company_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('company', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string()->notNull(),
|
||||
'description' => $this->text(),
|
||||
'status_id' => $this->integer(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
]);
|
||||
|
||||
$this->addForeignKey(
|
||||
'company_ibfk_status',
|
||||
'company',
|
||||
'status_id',
|
||||
'status',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('company_ibfk_status', 'company');
|
||||
|
||||
$this->dropTable('company');
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m181011_140904_add_column_to_fields_value
|
||||
*/
|
||||
class m181011_140904_add_column_to_fields_value extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('fields_value', 'company_id', $this->integer(11));
|
||||
|
||||
$this->addForeignKey(
|
||||
'fields_value_ibfk_company',
|
||||
'fields_value',
|
||||
'company_id',
|
||||
'company',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('fields_value_ibfk_company', 'fields_value');
|
||||
|
||||
$this->dropColumn('fields_value', 'project_id');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m181011_140904_add_column_to_fields_value cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
Reference in New Issue
Block a user