m160405_101056_create_slider_images.php 1.01 KB
<?php

use yii\db\Migration;

/**
 * Handles the creation for table `slider_images`.
 */
class m160405_101056_create_slider_images extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('slider_image', [
            'slider_image_id' => $this->primaryKey(),
            'slider_id' => $this->integer(),
            'image' => $this->string(255),
            'alt' => $this->string(255),
            'title' => $this->string(255),
            'url' => $this->string(255),
            'status' => $this->smallInteger(1),
            'sort' => $this->integer(6),
            'price' => $this->float(),
        ]);
        $this->addForeignKey('slider_slider_image_fk', 'slider_image', 'slider_id', 'slider', 'slider_id', 'CASCADE', 'CASCADE');
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropForeignKey('slider_slider_image_fk', '{{%slider_image}}');
        $this->dropTable('slider_image');
    }
}