Symfony:基本表或视图已存在:1050表"migration_versions"已存在 [英] Symfony: Base table or view already exists: 1050 Table 'migration_versions' already exists

查看:36
本文介绍了Symfony:基本表或视图已存在:1050表"migration_versions"已存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对migration_versions的操作做得非常糟糕,现在从migrations文件夹中删除了版本,尝试运行与迁移相关的任何操作时都会收到此错误.有人可以指出我在哪里解决这个问题的方向吗?

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?

如果我先删除数据库,然后再删除 make:migration ,则 migration_versions 表将出现在数据库中.之后,如果我尝试运行

If I drop the database and then make:migration, the migration_versions table appears in the db. After that if I try to run

php bin/console doctrine:migrations:migrate

我得到了错误:

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  

如果我随后从数据库中删除该表,则可以运行 php bin \ console doctrine:migrations:migrate 罚款.但是,当尝试运行任何其他 make:migration / doctrine:migrations:migrate 命令时,我得到与先前相同的错误,指出表 migration_versions 存在.

If I then drop that table from the db I can then run the php bin\console doctrine:migrations:migrate fine. 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.

推荐答案

由于配置中的schema_filter,发生了同样的问题.我的doctrine.yaml文件(Symfony 4)具有以下内容:

The same problem happened to me because of a schema_filter in my config. My doctrine.yaml file (Symfony 4) had the following:

doctrine:
    dbal:
        schema_filter: ~^(table_1|table_2|table_3)$~

我只需要像这样将"migration_versions"添加到模式过滤器中即可:

I had to simply add "migration_versions" to the schema filter like so:

doctrine:
    dbal:
        schema_filter: ~^(migration_versions|table_1|table_2|table_3)$~

这篇关于Symfony:基本表或视图已存在:1050表"migration_versions"已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆