主义-回滚所有迁移

时间:2020-01-03 17:31:32

标签: symfony doctrine migration

我似乎对Symfony和Doctrine遇到了一个奇怪的问题,其中一个具有可用迁移的积累,其中许多是重复的,有些旨在执行对不再存在的表的查询。

我希望仅回滚或“删除”所有这些可用的迁移,以便可以在新数据库上运行迁移,而一切将与代码中的情况相同。

下面是一个示例(这只是试运行):

  ++ migrating 20200103023439

     -> CREATE TABLE `user` (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled
 TINYINT(1) NOT NULL, salt VARCHAR(255) DEFAULT NULL, password VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, confirmation_token VARCHAR(180) DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL,
 roles LONGTEXT NOT NULL COMMENT '(DC2Type:array)', name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D64992FC23A8 (username_canonical), UNIQUE INDEX UNIQ_8D93D649A0D96FBF (email_canonical), UNIQUE INDEX UNIQ_8
D93D649C05FB297 (confirmation_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE entry (id INT AUTO_INCREMENT NOT NULL, album VARCHAR(255) NOT NULL, artist VARCHAR(255) NOT NULL, tracklist LONGTEXT NOT NULL COMMENT '(DC2Type:array)', review LONGTEXT NOT NULL, image VARC
HAR(255) NOT NULL, timestamp DATETIME NOT NULL, author VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE task (id INT AUTO_INCREMENT NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE track (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB

  ++ migrated (0s)

  ++ migrating 20200103023541

     -> CREATE TABLE entry (id INT AUTO_INCREMENT NOT NULL, album VARCHAR(255) NOT NULL, artist VARCHAR(255) NOT NULL, tracklist LONGTEXT NOT NULL COMMENT '(DC2Type:array)', review LONGTEXT NOT NULL, image VARC
HAR(255) NOT NULL, timestamp DATETIME NOT NULL, author VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE task (id INT AUTO_INCREMENT NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE track (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB

  ++ migrated (0s)

  ++ migrating 20200103023707

     -> CREATE TABLE entry (id INT AUTO_INCREMENT NOT NULL, album VARCHAR(255) NOT NULL, artist VARCHAR(255) NOT NULL, tracklist LONGTEXT NOT NULL COMMENT '(DC2Type:array)', review LONGTEXT NOT NULL, image VARC
HAR(255) NOT NULL, timestamp DATETIME NOT NULL, author VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE task (id INT AUTO_INCREMENT NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
     -> CREATE TABLE track (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB

  ++ migrated (0s)

您可以看到它正在尝试多次创建多个表,当实际运行此迁移时,这当然会导致许多错误。

我一直试图将其中一些版本向下迁移,但是即使这些也会导致SQLSTATE错误:

php bin / console准则:migrations:执行20200102235626 --down

任何帮助将不胜感激,我已经将这个问题缠了好几个小时。

1 个答案:

答案 0 :(得分:0)

啊,愚蠢的我!我不知道,我可以简单地删除DoctrineMigrations文件夹中的所有迁移PHP文件。