如何删除我在postgresql中创建的枚举类型值?
create type admin_level1 as enum('classifier', 'moderator', 'god');
Run Code Online (Sandbox Code Playgroud)
我想moderator从列表中删除.
我似乎无法在文档上找到任何内容.
我正在使用Postgresql 9.3.4.
我正在使用 Alembic 迁移工具在 SQLAlchemy 迁移中添加新的枚举成员。
SQLAlchemy 使用 Python 原生Enum:
from enum import Enum
class MyEnum(Enum):
# Key and value names different to clarify they are separate
# concepts in Python
old = "OLD_VALUE"
new1 = "NEW1_VALUE"
new2 = "NEW2_VALUE"
Run Code Online (Sandbox Code Playgroud)
进而:
class MyFantasticModel(Base):
__tablename__ = "fantasy"
enum_column = sa.Column(sa.Enum(MyEnum), nullable=False, index=True)
Run Code Online (Sandbox Code Playgroud)
我知道PostgreSQL在枚举迁移方面很困难,并且类似的问题已有低质量的答案。但我仍然想以半自动化的方式做到这一点。
使用Python 3.8。