Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calcio/ab0256fd5ae81c8c7ead0cadb4559535 to your computer and use it in GitHub Desktop.
Save calcio/ab0256fd5ae81c8c7ead0cadb4559535 to your computer and use it in GitHub Desktop.
<?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