use common\components\Migration\SafeMigration; /** * Handles the creation of table `` which is a junction between * table `` and table ``. */ class extends SafeMigration { /** * {@inheritdoc} */ public function safeUp() { $this->createTable('', [ '_id' => $this->integer(), '_id' => $this->integer(), 'PRIMARY KEY(_id, _id)', ]); $this->createIndex( 'idx-_id', '', '_id' ); $this->createIndex( 'idx-_id', '', '_id' ); $this->addForeignKey( 'fk-_id', '', '_id', '', 'id', 'CASCADE' ); $this->addForeignKey( 'fk-_id', '', '_id', '', 'id', 'CASCADE' ); } /** * {@inheritdoc} */ public function safeDown() { $this->dropTable(''); } }