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

doctrine:schema:drop does not drop schema in Postgres #548

Closed
humplebert opened this issue Jun 8, 2016 · 8 comments
Closed

doctrine:schema:drop does not drop schema in Postgres #548

humplebert opened this issue Jun 8, 2016 · 8 comments

Comments

@humplebert
Copy link

I've prepared the following simple wrapper script while developing my database with Doctrine annotations:

#!/usr/bin/env bash

php bin/console doctrine:schema:drop --force
php bin/console cache:clear
php bin/console doctrine:cache:clear-metadata --flush
php bin/console doctrine:schema:create
php bin/console doctrine:fixtures:load --purge-with-truncate

However, I notice that when doctrine:schema:drop is run, there are no SQL commands generated to drop the schema in my Postgres database. The results of my doctrine:schema:drop --dump-sql include:

...
DROP SEQUENCE account.user_id_seq CASCADE;
DROP SEQUENCE account.user_role_id_seq CASCADE;
DROP SEQUENCE account.user_scope_permission_id_seq CASCADE;
DROP TABLE system.schema_log;
DROP TABLE kernel.module;
DROP TABLE account.user_scope_permission;
DROP TABLE kernel.configuration;
DROP TABLE kernel.scope;
DROP TABLE kernel.code;
DROP TABLE kernel.code_module;
DROP TABLE kernel.configuration_scope;
DROP TABLE account.permission;
DROP TABLE account.role;
DROP TABLE account.user_role;
DROP TABLE account.assignment;
DROP TABLE account.role_permission

As you can see, there are no SQL statements for dropping the schema. And yet, doctrine:schema:create --dump-sql begins with the following:

CREATE SCHEMA system;
CREATE SCHEMA kernel;
CREATE SCHEMA account;
CREATE TABLE system.schema_log (id SERIAL NOT NULL, status_id INT DEFAULT NULL, created_id INT DEFAULT NULL, file_name VARCHAR(255) NOT NULL, created TIMESTAMP(0) WITH TIME ZONE NOT NULL, PRIMARY KEY(id));
CREATE UNIQUE INDEX UNIQ_38CD4290D7DF1668 ON system.schema_log (file_name);
CREATE INDEX IDX_38CD42906BF700BD ON system.schema_log (status_id);
...

Is it possible to update the doctrine:schema:drop command to include generation of statements to drop created schema when using Postgres?

@mikeSimonson
Copy link
Contributor

@AlanEdwardScott Can you paste a copy of your configuration ?

Thanks

@humplebert
Copy link
Author

@mikeSimonson

doctrine:
    dbal:
        driver:   pdo_pgsql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore
                auto_mapping:    true

@mikeSimonson
Copy link
Contributor

I am a little bit a loss.
You have only one database connection to one specific database but then it seems that your schema is also connected to 2 other databases.

@humplebert
Copy link
Author

This is PostgreSQL. A single database can have multiple schema. All three
schema exist within a single database. Hence the single connection.
On Jun 15, 2016 1:02 AM, "mikeSimonson" notifications@github.com wrote:

I am a little bit a loss.
You have only one database connection to one specific database but then it
seems that your schema is also connected to 2 other databases.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#548 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABxbkaQOS3_KiDu_P6go9oud4yiNudGMks5qL7GUgaJpZM4Ixe-6
.

@kimhemsoe
Copy link
Member

Can you write a unittest to reproduce this error? Also i think that dbal may be a better place to have this talk.

@humplebert
Copy link
Author

@kimhemsoe
I'll work on preparing a test and will submit the issue on dbal.

@cordoval
Copy link
Contributor

i am having the same problem @AlanEdwardScott how did you solve it?

@cordoval
Copy link
Contributor

cordoval commented Aug 17, 2017

This issue should be reopened.

I also did --dump-sql and it is not dropping the schema, it does drop everything inside but not the schema

so doing this manually:

DROP SCHEMA canary;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants