write migrations for documents
This commit is contained in:
30
console/migrations/m211223_090918_create_template_table.php
Normal file
30
console/migrations/m211223_090918_create_template_table.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%template}}`.
|
||||
*/
|
||||
class m211223_090918_create_template_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%template}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'title' => $this->string(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%template}}');
|
||||
}
|
||||
}
|
37
console/migrations/m211223_091152_create_document_table.php
Normal file
37
console/migrations/m211223_091152_create_document_table.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%document}}`.
|
||||
*/
|
||||
class m211223_091152_create_document_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%document}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'title' => $this->string(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
'template_id' => $this->integer(11)->notNull(),
|
||||
'manager_id' => $this->integer(11)->notNull(),
|
||||
]);
|
||||
|
||||
$this->addForeignKey('document_template', 'document', 'template_id', 'template', 'id');
|
||||
$this->addForeignKey('document_manager', 'document', 'manager_id', 'manager', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('document_manager', 'document');
|
||||
$this->dropForeignKey('document_template', 'document');
|
||||
$this->dropTable('{{%document}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%field}}`.
|
||||
*/
|
||||
class m211223_092038_create_document_field_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%document_field}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'title' => $this->string(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%document_field}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%template_field}}`.
|
||||
*/
|
||||
class m211223_092507_create_template_document_field_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%template_document_field}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'template_id' => $this->integer(11)->notNull(),
|
||||
'field_id' => $this->integer(11)->notNull()
|
||||
]);
|
||||
|
||||
$this->addForeignKey('template_template_document_field', 'template_document_field', 'template_id', 'template', 'id');
|
||||
$this->addForeignKey('document_field_template_document_field', 'template_document_field', 'field_id', 'document_field', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('template_template_document_field', 'template_document_field');
|
||||
$this->dropForeignKey('document_field_template_document_field', 'template_document_field');
|
||||
$this->dropTable('{{%template_document_field}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%field_value}}`.
|
||||
*/
|
||||
class m211223_095155_create_document_field_value_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%document_field_value}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'field_id' => $this->integer(11)->notNull(),
|
||||
'document_id' => $this->integer(11)->notNull(),
|
||||
'value' => $this->string()
|
||||
]);
|
||||
|
||||
$this->addForeignKey('document_field_document_field_value', 'document_field_value', 'field_id', 'document_field', 'id');
|
||||
$this->addForeignKey('document_document_field_value', 'document_field_value', 'document_id', 'document', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('document_field_document_field_value', 'document_field_value');
|
||||
$this->dropForeignKey('document_document_field_value', 'document_field_value');
|
||||
$this->dropTable('{{%document_field_value}}');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user