Created
March 24, 2017 13:09
-
-
Save calcio/ab0256fd5ae81c8c7ead0cadb4559535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use yii\db\Migration; | |
/** | |
* Handles the creation of table `product_images`. | |
*/ | |
class m170317_124609_create_product_images_table extends Migration | |
{ | |
/** | |
* @inheritdoc | |
*/ | |
public function up() | |
{ | |
$this->createTable('product_images', [ | |
'id' => $this->primaryKey(), | |
'product_id' => $this->integer()->notNull(), | |
'image_path' => $this->string(255), | |
'created_at' => $this->integer()->notNull(), | |
'updated_at' => $this->integer()->notNull(), | |
]); | |
$this->createIndex( | |
'idx-product_images-product_id', | |
'product_images', | |
'product_id' | |
); | |
$this->addForeignKey( | |
'fk-product_images-product_id', | |
'product_images', | |
'product_id', | |
'products', | |
'id', | |
'CASCADE' | |
); | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function down() | |
{ | |
$this->dropTable('product_images'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment