createTable('portfolio_user', [ 'portfolio_user_id' => $this->primaryKey(), 'portfolio_id' => $this->integer() ->notNull(), 'user_id' => $this->integer() ->notNull(), 'position' => $this->string(), 'time' => $this->integer(), 'status' => $this->integer() ->defaultValue(2) ->notNull(), ]); // add foreign key for table `portfolio` $this->addForeignKey('fk-portfolio_user-portfolio_id', 'portfolio_user', 'portfolio_id', 'portfolio', 'portfolio_id', 'CASCADE'); // add foreign key for table `user` $this->addForeignKey('fk-portfolio_user-user_id', 'portfolio_user', 'user_id', 'user', 'id', 'CASCADE'); $this->createIndex('unique_portfolio_user_key', 'portfolio_user', ['portfolio_id', 'user_id'], true); } /** * @inheritdoc */ public function down() { $this->dropIndex('unique_portfolio_user_key', 'portfolio_user'); // drops foreign key for table `portfolio` $this->dropForeignKey('fk-portfolio_user-portfolio_id', 'portfolio_user'); // drops foreign key for table `user` $this->dropForeignKey('fk-portfolio_user-user_id', 'portfolio_user'); $this->dropTable('portfolio_user'); } }