createTable('{{%addresses}}', [ 'id' => $this->primaryKey(), 'address' => $this->string(255)->notNull(), 'company_id' => $this->integer(11)->notNull(), 'name' => $this->string(255), ]); $this->createIndex('idx-addresses-company_id', 'addresses', 'company_id'); $this->addForeignKey( 'fk-addresses-company_id', 'addresses', 'company_id', 'company', 'id', 'CASCADE' ); } /** * {@inheritdoc} */ public function safeDown() { $this->dropForeignKey( 'fk-addresses-company_id', 'addresses' ); // drops index for column `author_id` $this->dropIndex( 'idx-addresses-company_id', 'addresses' ); $this->dropTable('{{%addresses}}'); } }