Answer the question
In order to leave comments, you need to log in
Why didn't the transaction work when rolling back a migration in yii2?
There is a migration written via safeUp()/safeDown().
Performed migration, decided to rollback
public function safeDown()
{
$this->dropTable('{{%post_tags}}');
$this->dropTable('{{%tags}}');
$this->dropTable('{{%category}}');
$this->dropTable('{{%post}}');
}
Answer the question
In order to leave comments, you need to log in
If the database is MySQL, then there, if my memory serves me, transactions for creating / deleting tables do not work. Faced a similar problem when creating tables, for example:
Create table A, add foreign key A to B. All this is wrapped in safeUp. If there is an error in the description of creating key B, then the migration will create table A, and an exception will be thrown to create the key. Having edited this migration, when you try to apply it again, an exception will fly out that table A already exists.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question