createTable('post_tag', [ 'post_id' => \$this->integer(), 'tag_id' => \$this->integer(), 'PRIMARY KEY(post_id, tag_id)', ]); // creates index for column `post_id` \$this->createIndex( 'idx-post_tag-post_id', 'post_tag', 'post_id' ); // add foreign key for table `post` \$this->addForeignKey( 'fk-post_tag-post_id', 'post_tag', 'post_id', 'post', 'id', 'CASCADE' ); // creates index for column `tag_id` \$this->createIndex( 'idx-post_tag-tag_id', 'post_tag', 'tag_id' ); // add foreign key for table `tag` \$this->addForeignKey( 'fk-post_tag-tag_id', 'post_tag', 'tag_id', 'tag', 'id', 'CASCADE' ); } /** * @inheritdoc */ public function down() { // drops foreign key for table `post` \$this->dropForeignKey( 'fk-post_tag-post_id', 'post_tag' ); // drops index for column `post_id` \$this->dropIndex( 'idx-post_tag-post_id', 'post_tag' ); // drops foreign key for table `tag` \$this->dropForeignKey( 'fk-post_tag-tag_id', 'post_tag' ); // drops index for column `tag_id` \$this->dropIndex( 'idx-post_tag-tag_id', 'post_tag' ); \$this->dropTable('post_tag'); } } CODE;