m211118_133135_create_tile_table.php 851 Bytes
<?php

use yii\db\Migration;

/**
 * Handles the creation of table `tile`.
 */
class m211118_133135_create_tile_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('tile', [
            'id' => $this->primaryKey(),
            'status'             => $this->boolean(),
            'sort'             => $this->smallInteger(),
            'image_id'        => $this->integer(),
        ]);
        $this->addForeignKey(
            'fk-tile-image_id',
            'tile',
            'image_id',
            'ImageManager',
            'id',
            'CASCADE'
        );
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropForeignKey(
            'fk-tile-image_id',
            'tile'
        );
        $this->dropTable('tile');
    }
}