reports
This commit is contained in:
51
console/migrations/m200204_125649_create_reports_table.php
Normal file
51
console/migrations/m200204_125649_create_reports_table.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%reports}}`.
|
||||
*/
|
||||
class m200204_125649_create_reports_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%reports}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'created_at' => $this->date()->notNull(),
|
||||
'today' => $this->string()->notNull(),
|
||||
'difficulties' => $this->string(),
|
||||
'tomorrow' => $this->string(),
|
||||
'status' => $this->integer()
|
||||
]);
|
||||
|
||||
$this->addColumn('{{%reports}}', 'user_card_id', $this->integer()->notNull());
|
||||
|
||||
// creates index for column `user_card_id`
|
||||
$this->createIndex(
|
||||
'{{%idx-reports-user_card_id}}',
|
||||
'{{%reports}}',
|
||||
'user_card_id'
|
||||
);
|
||||
|
||||
// add foreign key for table `{{%user_card}}`
|
||||
$this->addForeignKey(
|
||||
'{{%fk-reports-user_card_id}}',
|
||||
'{{%reports}}',
|
||||
'user_card_id',
|
||||
'{{%user_card}}',
|
||||
'id',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%reports}}');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user