Merge "Fix DB2 column 'id' autoincrement issue"
This commit is contained in:
commit
466937da1f
|
@ -84,7 +84,15 @@ def upgrade(migrate_engine):
|
|||
cons = constraint.PrimaryKeyConstraint('tmp_id', table=event_table)
|
||||
cons.create()
|
||||
|
||||
event_table.c.tmp_id.alter(sqlalchemy.Integer, autoincrement=True)
|
||||
if migrate_engine.name == 'ibm_db_sa':
|
||||
# NOTE(chenxiao): For DB2, setting "ID" column "autoincrement=True"
|
||||
# can't make sense after above "tmp_id=>id" transformation,
|
||||
# so should work around it.
|
||||
sql = "ALTER TABLE EVENT ALTER COLUMN ID SET GENERATED BY " \
|
||||
"DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1)"
|
||||
migrate_engine.execute(sql)
|
||||
else:
|
||||
event_table.c.tmp_id.alter(sqlalchemy.Integer, autoincrement=True)
|
||||
|
||||
|
||||
def upgrade_sqlite(migrate_engine):
|
||||
|
|
Loading…
Reference in New Issue