123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- use yii\db\Migration;
- /**
- * Class m221227_033116_add_gallery_table
- */
- class m221227_033116_add_gallery_table extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $this->createTable("{{%gallery}}",[
- "id"=>$this->primaryKey(),
- "name"=>$this->string(),
- "description"=>$this->string(),
- "created_at"=>$this->dateTime(),
- "post_id"=>$this->integer(10)->unsigned()
- ]);
- $this->createTable("{{%gallery_item}}",[
- "id"=>$this->primaryKey(),
- "name"=>$this->string(),
- "description"=>$this->string(),
- "created_at"=>$this->dateTime(),
- "gallery_id"=>$this->integer(),
- "path"=>$this->string(),
- "ext"=>$this->string()
- ]);
- $this->addForeignKey("gallery_to_post_fk","{{%gallery}}",'post_id','{{%news}}','id','CASCADE','CASCADE');
- $this->addForeignKey("gallery_item_to_gallery_fk","{{%gallery_item}}",'gallery_id','{{%gallery}}','id','CASCADE','CASCADE');
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "m221227_033116_add_gallery_table cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "m221227_033116_add_gallery_table cannot be reverted.\n";
- return false;
- }
- */
- }
|