简体   繁体   English

Symfony:基表或视图已存在:1050 表“migration_versions”已存在

[英]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:我用以下方法修复了它:

  • I removed the database content and the migrations/Versionfiles.我删除了数据库内容和迁移/版本文件。
  • Did bin/console make:migration是否bin/console make:migration
  • And bin/console doctrine:migrations:migratebin/console doctrine:migrations:migrate

and it worked again.它再次起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony 5:基表或视图已存在:1050 表“migration_versions”已存在 - Symfony 5: Base table or view already exists: 1050 Table 'migration_versions' already exists Laravel Forge:基本表或视图已存在:1050表已存在 - Laravel Forge: Base table or view already exists: 1050 Table already exists 基本表或视图已存在:1050表'sales_flat_order'已存在 - Base table or view already exists: 1050 Table 'sales_flat_order' already exists Laravel 5.5 错误基本表或视图已存在:1050 表“用户”已存在 - Laravel 5.5 Error Base table or view already exists: 1050 Table 'users' already exists Laravel迁移:基本表或视图已存在 - Laravel Migration: Base table or view already exists SQLSTATE [42S01]:基本表或视图已存在或基本表或视图已存在:1050表 - SQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Table SQLSTATE[42S01]:基表或视图已存在:1050 表“付款”已存在(SQL:创建表“付款” - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'payments' already exists (SQL: create table `payments` SQLSTATE [42S01]:基本表或视图已存在:1050表'weee_tax'已存在,查询为 - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'weee_tax' already exists, query was Illuminate\Database\QueryException SQLSTATE[42S01]:基表或视图已存在:1050 表“发票”已存在 - Illuminate\Database\QueryException SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'invoices' already exists Laravel 错误:SQLSTATE[42S01]:基表或视图已存在:1050 表“类别”已存在 - Laravel Error : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'categories' already exists
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM