m220412_144550_create_product_table.php 929 Bytes
<?php

use yii\db\Migration;

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

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