doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.94k stars 2.52k forks source link

`doctrine:schema:drop` does not remove custom schema in PostgreSQL #11701

Open nikophil opened 3 weeks ago

nikophil commented 3 weeks ago

Bug Report

Q A
Version all

Summary

(sorry if the the error has already been reported, I've only found https://github.com/doctrine/DoctrineBundle/issues/548 for which a user said it should be reopened)

Given we have an entity which declares a custom schema:

#[ORM\Entity]
#[ORM\Table(name: 'article', schema: 'custom')]

In PostgreSQL, doctrine:schema:create and doctrine:schema:update will create a "schema" named custom, next to the default public one. But doctrine:schema:drop will not drop this newly created schema.

Current behavior

The following is creating an error:

$ bin/console doctrine:database:create
$ bin/console doctrine:schema:create -f
$ bin/console doctrine:schema:drop -f --full-database
$ bin/console doctrine:schema:create -f

Schema-Tool failed with Error 'An exception occurred while executing a query: SQLSTATE[42P06]: Duplicate schema: 7 ERROR: schema "custom" already exists' while executing DDL: CREATE SCHEMA custom

Expected behavior

I'd expect doctrine:schema:drop to emit a DROP SCHEMA custom.

Please, let me know if this is a bug or the desired behavior. I'd be happy to provide a fix.

greg0ire commented 3 weeks ago

Hi, I think this is a bug. Just to be sure, you're using dbal 4, right?

nikophil commented 3 weeks ago

Yes I do, but I'm pretty sure the problem did existe with dbal 3 and or orm 2 BTW should I provide a fix for both versions?

greg0ire commented 3 weeks ago

If you can, please do.