- edited description
PostgreSQL Enum not automatically dropped
Issue #3319
resolved
I have some problem when I try to drop al the tables in the db.
https://github.com/hachreak/invenio/blob/master/invenio/base/scripts/database.py#L165
When it's invoked, all the tables are correctly dropped, but the Enum (Type in PostgreSQL) are not dropped. Do you have some ideas how can I resolve this problem? :)
Enum example: https://github.com/hachreak/invenio/blob/master/invenio/modules/access/models.py#L57
Comments (6)
-
reporter -
reporter - changed component to postgres
-
repo owner - changed milestone to 1.0
at the moment it only takes place if you do a drop for the whole MetaData. as a workaround, you can drop the type directy:
from sqlalchemy.dialects.postgresql import ENUM ENUM(name='abc').drop(engine)
-
reporter It's possible to automatically list all defined Enum from metadata?
-
repo owner - changed status to resolved
- The Postgresql :class:
.postgresql.ENUM
type will emit a DROP TYPE instruction when a plaintable.drop()
is called, assuming the object is not associated directly with a :class:.MetaData
object. In order to accomodate the use case of an enumerated type shared between multiple tables, the type should be associated directly with the :class:.MetaData
object; in this case the type will only be created at the metadata level, or if created directly. The rules for create/drop of Postgresql enumerated types have been highly reworked in general. fixes#3319
→ <<cset 71b8df2e5319>>
-
repo owner within the metadata you can search:
result = [] for table in metadata.tables.values(): for column in table.c: if isinstance(column.type, Enum): result.add(column.type.name)
- Log in to comment