db->getSchema()->getTableSchema('rescue_animal_gallery_link', true) !== null) { return; } $this->safeCreateTable('rescue_animal_gallery_link', [ 'id' => $this->primaryKey(), 'animal_id' => $this->integer()->notNull(), 'gallery_id' => $this->integer()->notNull(), 'contentcontainer_id' => $this->integer()->notNull(), 'created_at' => $this->dateTime()->null(), 'updated_at' => $this->dateTime()->null(), ]); $this->safeCreateIndex('idx_rescue_animal_gallery_link_animal', 'rescue_animal_gallery_link', 'animal_id', true); $this->safeCreateIndex('idx_rescue_animal_gallery_link_gallery', 'rescue_animal_gallery_link', 'gallery_id', true); $this->safeCreateIndex('idx_rescue_animal_gallery_link_container', 'rescue_animal_gallery_link', 'contentcontainer_id', false); if ($this->db->getSchema()->getTableSchema('rescue_animal', true) !== null) { $this->safeAddForeignKey( 'fk_rescue_animal_gallery_link_animal', 'rescue_animal_gallery_link', 'animal_id', 'rescue_animal', 'id', 'CASCADE', 'CASCADE' ); } if ($this->db->getSchema()->getTableSchema('gallery_gallery', true) !== null) { $this->safeAddForeignKey( 'fk_rescue_animal_gallery_link_gallery', 'rescue_animal_gallery_link', 'gallery_id', 'gallery_gallery', 'id', 'CASCADE', 'CASCADE' ); } } public function safeDown() { $this->safeDropTable('rescue_animal_gallery_link'); } }