guild/console/migrations/m221108_135939_create_document_table.php

43 lines
1.4 KiB
PHP
Raw Normal View History

2022-11-08 18:01:42 +03:00
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%document}}`.
*/
class m221108_135939_create_document_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%document}}', [
'id' => $this->primaryKey(),
'company_id' => $this->integer(11)->notNull(),
2022-11-10 16:00:43 +03:00
'contractor_company_id' => $this->integer(11)->notNull(),
2022-11-08 18:01:42 +03:00
'manager_id' => $this->integer(11)->notNull(),
'contractor_manager_id' => $this->integer(11)->notNull(),
2022-11-10 16:00:43 +03:00
'template_id' => $this->integer(11)->notNull(),
'title' => $this->string(),
'body' => $this->text(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
2022-11-08 18:01:42 +03:00
]);
$this->addForeignKey('company_document', 'document', 'company_id', 'company', 'id');
$this->addForeignKey('contractor_company_document', 'document', 'contractor_company_id', 'company', 'id');
$this->addForeignKey('manager_document', 'document', 'manager_id','manager', 'id');
$this->addForeignKey('contractor_manager_document', 'document', 'contractor_manager_id','manager', 'id');
2022-11-10 16:00:43 +03:00
$this->addForeignKey('document_template_document', 'document', 'template_id','document_template', 'id');
2022-11-08 18:01:42 +03:00
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%document}}');
}
}