From 99415859457b51d725b7f100af9cba780e67ec4d Mon Sep 17 00:00:00 2001 From: Jesus Perez Date: Tue, 19 Jan 2016 09:20:09 +0100 Subject: [PATCH] Fix migrations to maintain compatibility with sqlite The current command used for alter a column (drop or alter) missing the compatibility with sqllite. Solution, pass by using batch alembic. Read http://alembic.readthedocs.org/en/latest/batch.html for more info. Change-Id: I32c5cecaad111f2bde559de74ecefa339739b994 --- .../versions/010_remove_unused_networking_column.py | 6 ++++-- .../versions/012_support_domain_users.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/murano/db/migration/alembic_migrations/versions/010_remove_unused_networking_column.py b/murano/db/migration/alembic_migrations/versions/010_remove_unused_networking_column.py index 43735f58..63d2cd6e 100644 --- a/murano/db/migration/alembic_migrations/versions/010_remove_unused_networking_column.py +++ b/murano/db/migration/alembic_migrations/versions/010_remove_unused_networking_column.py @@ -31,8 +31,10 @@ MYSQL_CHARSET = 'utf8' def upgrade(): - op.drop_column('environment', 'networking') - op.drop_column('environment-template', 'networking') + with op.batch_alter_table("environment") as batch_op: + batch_op.drop_column('networking') + with op.batch_alter_table("environment-template") as batch_op2: + batch_op2.drop_column('networking') def downgrade(): diff --git a/murano/db/migration/alembic_migrations/versions/012_support_domain_users.py b/murano/db/migration/alembic_migrations/versions/012_support_domain_users.py index bea0e412..86034f71 100644 --- a/murano/db/migration/alembic_migrations/versions/012_support_domain_users.py +++ b/murano/db/migration/alembic_migrations/versions/012_support_domain_users.py @@ -33,12 +33,16 @@ MYSQL_CHARSET = 'utf8' def upgrade(): - op.alter_column('session', 'user_id', type_=sa.String(64), nullable=False) - op.alter_column('package', 'owner_id', type_=sa.String(64), nullable=False) + with op.batch_alter_table("session") as batch_op: + batch_op.alter_column('user_id', type_=sa.String(64), nullable=False) + with op.batch_alter_table("package") as batch_op2: + batch_op2.alter_column('owner_id', type_=sa.String(64), nullable=False) # end Alembic commands # def downgrade(): - op.alter_column('package', 'owner_id', type_=sa.String(36), nullable=False) - op.alter_column('session', 'user_id', type_=sa.String(36), nullable=False) + with op.batch_alter_table("session") as batch_op: + batch_op.alter_column('user_id', type_=sa.String(36), nullable=False) + with op.batch_alter_table("package") as batch_op2: + batch_op2.alter_column('owner_id', type_=sa.String(36), nullable=False) # end Alembic commands #