mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
Manually handle the new Enum creation
Alembic does not handle postgres Enums correctly, so we need to manually generate the new enum type. See https://github.com/sqlalchemy/alembic/issues/278
This commit is contained in:
parent
ee12618b3b
commit
9eb18f2f99
1 changed files with 7 additions and 1 deletions
|
@ -16,10 +16,16 @@ from ihatemoney.models import BillType
|
|||
|
||||
|
||||
def upgrade():
|
||||
op.add_column("bill", sa.Column("bill_type", sa.Enum(BillType), server_default=BillType.EXPENSE.name))
|
||||
billtype_enum = sa.Enum(BillType)
|
||||
billtype_enum.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
op.add_column("bill", sa.Column("bill_type", billtype_enum, server_default=BillType.EXPENSE.name))
|
||||
op.add_column("bill_version", sa.Column("bill_type", sa.UnicodeText()))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column("bill", "bill_type")
|
||||
op.drop_column("bill_version", "bill_type")
|
||||
|
||||
billtype_enum = sa.Enum(BillType)
|
||||
billtype_enum.drop(op.get_bind())
|
Loading…
Reference in a new issue