first commit
This commit is contained in:
68
console/migrations/m231019_110637_create_order_table.php
Executable file
68
console/migrations/m231019_110637_create_order_table.php
Executable file
@ -0,0 +1,68 @@
|
||||
<?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}}');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user