PGSQL: create Enum before using
For a reason, Enums in PostgreSQL migrations require explicit create[1][2]. This patch changes the introspection state Enum definition from a declaration to an explicit construction to avoid the issue. [1] http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#sqlalchemy.dialects.postgresql.ENUM [2] https://bitbucket.org/zzzeek/alembic/issues/67/autogenerate-with-enums-on-postgres-dont#comment-4100435 Change-Id: I817ce6e42c0ea4ae66369f5569130c7cdc793c83 Closes-Bug: 1696950
This commit is contained in:
parent
a46e708160
commit
bc546fc0cd
|
@ -36,10 +36,12 @@ Node = sql.table('nodes',
|
|||
|
||||
|
||||
def upgrade():
|
||||
state_enum = sa.Enum(*istate.States.all(), name='node_state')
|
||||
state_enum.create(op.get_bind())
|
||||
|
||||
op.add_column('nodes', sa.Column('version_id', sa.String(36),
|
||||
server_default=''))
|
||||
op.add_column('nodes', sa.Column('state', sa.Enum(*istate.States.all(),
|
||||
name='node_state'),
|
||||
op.add_column('nodes', sa.Column('state', state_enum,
|
||||
nullable=False,
|
||||
default=istate.States.finished,
|
||||
server_default=istate.States.finished))
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Create the node_state enum explicitly in the migration, as it is required
|
||||
by PostgreSQL
|
Loading…
Reference in New Issue