Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema "public" already exists #16278

Open
nbro opened this issue May 20, 2024 · 0 comments
Open

schema "public" already exists #16278

nbro opened this issue May 20, 2024 · 0 comments
Assignees
Labels
Environment Environment (OS, databases, libraries, etc.) specific issues. Potential Bug Potential bugs or bugfixes, that needs to be reproduced.

Comments

@nbro
Copy link

nbro commented May 20, 2024

Sylius version affected: ~1.13.0

Description

I get errors like schema "public" already exists when executing (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create) when setting up a new Sylius plugin, as explained in the README: https://github.com/Sylius/PluginSkeleton?tab=readme-ov-file#traditional

Note that I've executed this command after (cd tests/Application && APP_ENV=test bin/console doctrine:database:create), which indeed creates a database in my PostgreSQL. If I inspect the database, there's indeed public schema already.

Full stack trace


 !                                                                                                                      
 ! [CAUTION] This operation should not be executed in a production environment!                                         
 !                                                                                                                      

 Creating database schema...


In ToolsException.php line 19:
                                                                                                                                         
  Schema-Tool failed with Error 'An exception occurred while executing a query: SQLSTATE[42P06]: Duplicate schema: 7 ERROR:  schema "pu  
  blic" already exists' while executing DDL: CREATE SCHEMA public                                                                        
                                                                                                                                         

In ExceptionConverter.php line 87:
                                                                                                                              
  An exception occurred while executing a query: SQLSTATE[42P06]: Duplicate schema: 7 ERROR:  schema "public" already exists  
                                                                                                                              

In Exception.php line 28:
                                                                               
  SQLSTATE[42P06]: Duplicate schema: 7 ERROR:  schema "public" already exists  
                                                                               

In Connection.php line 33:
                                                                               
  SQLSTATE[42P06]: Duplicate schema: 7 ERROR:  schema "public" already exists  
                                                                               

doctrine:schema:create [--em EM] [--dump-sql]

Steps to reproduce

Follow the instructions here https://github.com/Sylius/PluginSkeleton and in the documentation https://docs.sylius.com/en/latest/book/plugins/guide/naming.html

Notes

  • If I do (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create --dump-sql), I indeed see that the command doctrine:schema:create tried to create the schema public
CREATE SCHEMA public;
CREATE SEQUENCE sylius_currency_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE SEQUENCE sylius_exchange_rate_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE SEQUENCE sylius_locale_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE SEQUENCE sylius_product_association_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
...

Possible Solution

I am not sure.

There are some workarounds here doctrine/dbal#1110, but I'm not sure how to adapt them to the sylius plugin case. I suppose may need to add these workarounds inside tests/Application, but it would be nice to have an authoritative answer from a Sylius developer

@CoderMaggie CoderMaggie added Potential Bug Potential bugs or bugfixes, that needs to be reproduced. Environment Environment (OS, databases, libraries, etc.) specific issues. labels Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Environment Environment (OS, databases, libraries, etc.) specific issues. Potential Bug Potential bugs or bugfixes, that needs to be reproduced.
Projects
None yet
Development

No branches or pull requests

3 participants