Merge "Fix sqlalchemy migration script 061 for DB2 backend"
This commit is contained in:
commit
ad579adb88
@ -20,6 +20,19 @@ def upgrade(migrate_engine):
|
|||||||
|
|
||||||
for tab_name in ['stack', 'resource', 'software_deployment']:
|
for tab_name in ['stack', 'resource', 'software_deployment']:
|
||||||
table = sqlalchemy.Table(tab_name, meta, autoload=True)
|
table = sqlalchemy.Table(tab_name, meta, autoload=True)
|
||||||
|
if migrate_engine.name == 'ibm_db_sa':
|
||||||
|
status_reason = sqlalchemy.Column('new_status_reason',
|
||||||
|
sqlalchemy.Text)
|
||||||
|
table.create_column(status_reason)
|
||||||
|
qry = table.select().execute().fetchall()
|
||||||
|
for item in qry:
|
||||||
|
values = {'new_status_reason': item.status_reason}
|
||||||
|
update = table.update().where(
|
||||||
|
table.c.id == item.id).values(values)
|
||||||
|
migrate_engine.execute(update)
|
||||||
|
table.c.status_reason.drop()
|
||||||
|
table.c.new_status_reason.alter(name='status_reason')
|
||||||
|
else:
|
||||||
table.c.status_reason.alter(type=sqlalchemy.Text)
|
table.c.status_reason.alter(type=sqlalchemy.Text)
|
||||||
|
|
||||||
|
|
||||||
@ -29,4 +42,17 @@ def downgrade(migrate_engine):
|
|||||||
|
|
||||||
for tab_name in ['stack', 'resource', 'software_deployment']:
|
for tab_name in ['stack', 'resource', 'software_deployment']:
|
||||||
table = sqlalchemy.Table(tab_name, meta, autoload=True)
|
table = sqlalchemy.Table(tab_name, meta, autoload=True)
|
||||||
|
if migrate_engine.name == 'ibm_db_sa':
|
||||||
|
status_reason = sqlalchemy.Column('new_status_reason',
|
||||||
|
sqlalchemy.String(255))
|
||||||
|
table.create_column(status_reason)
|
||||||
|
qry = table.select().execute().fetchall()
|
||||||
|
for item in qry:
|
||||||
|
values = {'new_status_reason': item.status_reason}
|
||||||
|
update = table.update().where(
|
||||||
|
table.c.id == item.id).values(values)
|
||||||
|
migrate_engine.execute(update)
|
||||||
|
table.c.status_reason.drop()
|
||||||
|
table.c.new_status_reason.alter(name='status_reason')
|
||||||
|
else:
|
||||||
table.c.status_reason.alter(type=sqlalchemy.String(255))
|
table.c.status_reason.alter(type=sqlalchemy.String(255))
|
||||||
|
Loading…
Reference in New Issue
Block a user