R
R
Ruslan Absalyamov2019-04-23 18:41:49
Yii
Ruslan Absalyamov, 2019-04-23 18:41:49

Why do I get an error after a rollback?

When I specify php yii migrate/downthat I receive the answer
Migration failed. The rest of the migrations are cancelled.
How can I fix it? I already installed php7.1-mysql but nothing helped

<?php

use yii\db\Migration;

/**
 * Class m190423_135654_add_archive_column_user_table
 */
class m190423_135654_add_archive_column_user_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->execute("ALTER TABLE `user`
ADD `archive` int(11) NULL;");

        $this->execute("ALTER TABLE `user`
ADD `archive_сomment` text NULL;");

        $this->execute("ALTER TABLE `user`
ADD `reason_archive` int(11) NULL;");
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m190423_135654_add_archive_column_user_table cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190423_135654_add_archive_column_user_table cannot be reverted.\n";

        return false;
    }
    */
}

At the same time, migrations are rolled, but not rolled back.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-04-23
@rusline18

return false;

That's why
But in general it is worth describing the rollback in public function safeDown(). What do you expect if you have not described any logic? Describe the rollback logic and return true.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question