PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

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

 January 20, 2022     api-platform.com, doctrine-orm, symfony     No comments   

Issue

I am creating entities in the API Platform. Everytime I add a new entity or modify a field I run

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

to synchronize the schema. I faced no problems this far but after I created a datetime field and tried synchronizing I get a table already exists error

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

In the normal case I would have just dropped the tables and recreated it but since I am using the API Platform within docker I have no access to the database. Is there a way to resolve this?


Solution

Managed to figure this out. I dropped the database by running the following command

docker-compose exec php bin/console doctrine:database:drop --force

Then recreated the database using this statement from the command line

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

Then updated the schema using this statement

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

Updating database schema...

     6 queries were executed

     [OK] Database schema updated successfully!                                                                            


Answered By - sridhar pandurangiah
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing