SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation while synchronizing entity changes in API Platfrom

SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation while synchronizing entity changes in API Platfrom

我正在 API 平台中创建实体。每次我添加一个新实体或修改一个字段时,我 运行

docker-compose exec php bin/console doctrine:schema:update --force

同步架构。到目前为止我没有遇到任何问题,但是在我创建了一个日期时间字段并尝试同步之后,我得到了一个 table 已经存在的错误

In AbstractPostgreSQLDriver.php line 66:
An exception occurred while executing 'CREATE SEQUENCE financial_statement_templates_definition_fstemplate_definition_id_seq INCREMENT BY 1 MINVALUE 1 START 1':  

In PDOConnection.php line 83:
SQLSTATE[42P07]: Duplicate table: 7 ERROR:  relation "financial_statement_templates_definition_fstemplate_definition_" already exists  

In PDOConnection.php line 78:
SQLSTATE[42P07]: Duplicate table: 7 ERROR:  relation "financial_statement_templates_definition_fstemplate_definition_" already exists

在正常情况下,我会删除 table 并重新创建它,但由于我在 docker 中使用 API 平台,所以我无法访问数据库。有办法解决这个问题吗?

设法解决了这个问题。我通过 运行 以下命令

删除了数据库
docker-compose exec php bin/console doctrine:database:drop --force

然后从命令行使用此语句重新创建数据库

docker-compose exec php bin/console doctrine:database:create

然后使用此语句更新架构

docker-compose exec php bin/console doctrine:schema:update --force

Updating database schema...

     6 queries were executed

     [OK] Database schema updated successfully!