[英]Symfony: Base table or view already exists: 1050 Table 'migration_versions' already exists
I've done something horribly wrong to my migration_versions, deleted the versions from the migrations folder now and I get this error when try to run anything to do with migrations.我对我的迁移版本做了一些可怕的错误,现在从迁移文件夹中删除了版本,当我尝试运行与迁移有关的任何内容时出现此错误。 Could someone point me in the direction of where to start to fix this?
有人能指出我从哪里开始解决这个问题吗?
If I drop the database and then make:migration
, the migration_versions
table appears in the db.如果我删除数据库然后
make:migration
,则migration_versions
表将出现在数据库中。 After that if I try to run之后,如果我尝试运行
php bin/console doctrine:migrations:migrate
I get the error:我得到错误:
In AbstractMySQLDriver.php line 38:
An exception occurred while executing 'CREATE TABLE migration_versions (version VARCHAR(14) NOT NULL, executed_at
DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', PRIMARY KEY(version)) DEFAULT CHARACTER SET utf8mb4 COLL
ATE `utf8mb4_unicode_ci` ENGINE = InnoDB':
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migration_versions' already exists
In PDOConnection.php line 43:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migration_versions' already exists
In PDOConnection.php line 41:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migration_versions' already exists
If I then drop that table from the db I can then run the php bin\console doctrine:migrations:migrate
fine.如果我然后从数据库中删除该表,我可以运行
php bin\console doctrine:migrations:migrate
很好。 But when attempting to run any further make:migration
/ doctrine:migrations:migrate
commands I get the same error as previous stating that the table migration_versions
exists.但是,当尝试运行任何进一步的
make:migration
/ doctrine:migrations:migrate
命令时,我得到与之前相同的错误,即表migration_versions
存在。
The same problem happened to me because of a schema_filter in my config.由于我的配置中的 schema_filter,我也遇到了同样的问题。 My doctrine.yaml file (Symfony 4) had the following:
我的 doctrine.yaml 文件(Symfony 4)具有以下内容:
doctrine:
dbal:
schema_filter: ~^(table_1|table_2|table_3)$~
I had to simply add "migration_versions" to the schema filter like so:我必须像这样简单地将“migration_versions”添加到模式过滤器中:
doctrine:
dbal:
schema_filter: ~^(migration_versions|table_1|table_2|table_3)$~
I had a similar issue, where I only wanted to change a field name.我有一个类似的问题,我只想更改一个字段名称。
The same problem happend after changing the fieldname and try to migrate that with the two commands.更改字段名并尝试使用两个命令迁移该字段名后发生了同样的问题。
I fixed it with:我用以下方法修复了它:
bin/console make:migration
bin/console make:migration
bin/console doctrine:migrations:migrate
bin/console doctrine:migrations:migrate
and it worked again.它再次起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.