69 lines
1.5 KiB
PHP
Executable File
69 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
use yii\db\Migration;
|
|
|
|
/**
|
|
* Handles the creation of table `{{%order}}`.
|
|
*/
|
|
class m231019_110637_create_order_table extends Migration
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function safeUp()
|
|
{
|
|
$this->createTable('{{%order}}', [
|
|
'id' => $this->primaryKey(),
|
|
'user_id' => $this->integer(),
|
|
'table_id' => $this->integer(),
|
|
'strength' => $this->tinyInteger(),
|
|
'amount' => $this->float(),
|
|
'status' => $this->tinyInteger(),
|
|
'created_at' => $this->timestamp(),
|
|
'updated_at' => $this->timestamp(),
|
|
]);
|
|
|
|
$this->createIndex(
|
|
'idx-order-user_id',
|
|
'order',
|
|
'user_id'
|
|
);
|
|
|
|
$this->addForeignKey(
|
|
'fk-order-user_id',
|
|
'order',
|
|
'user_id',
|
|
'user',
|
|
'id',
|
|
'CASCADE'
|
|
);
|
|
|
|
$this->createIndex(
|
|
'idx-order-table_id',
|
|
'order',
|
|
'table_id'
|
|
);
|
|
|
|
$this->addForeignKey(
|
|
'fk-order-table_id',
|
|
'order',
|
|
'table_id',
|
|
'table',
|
|
'id',
|
|
'CASCADE'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function safeDown()
|
|
{
|
|
$this->dropForeignKey('fk-order-user_id', 'order');
|
|
$this->dropIndex('idx-order-user_id', 'order');
|
|
$this->dropForeignKey('fk-order-table_id', 'order');
|
|
$this->dropIndex('idx-order-table_id', 'order');
|
|
$this->dropTable('{{%order}}');
|
|
}
|
|
}
|