Browse Source

Don't run these migrations for MySQL

See #309.
Peter Justin 7 years ago
parent
commit
8b8de289a1
1 changed files with 21 additions and 14 deletions
  1. 21 14
      migrations/201705041144_933bd7d807c4_add_more_non_nullables.py

+ 21 - 14
migrations/201705041144_933bd7d807c4_add_more_non_nullables.py

@@ -17,6 +17,8 @@ depends_on = None
 
 
 def upgrade():
+    connection = op.get_bind()
+
     # ### commands auto generated by Alembic - please adjust! ###
     with op.batch_alter_table('conversations', schema=None) as batch_op:
         batch_op.alter_column('date_created',
@@ -28,13 +30,15 @@ def upgrade():
                existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
                nullable=False)
 
-    with op.batch_alter_table('groups_users', schema=None) as batch_op:
-        batch_op.alter_column('group_id',
-               existing_type=sa.INTEGER(),
-               nullable=False)
-        batch_op.alter_column('user_id',
-               existing_type=sa.INTEGER(),
-               nullable=False)
+    # See https://github.com/sh4nks/flaskbb/issues/309
+    if connection.engine.dialect.name != "mysql":
+        with op.batch_alter_table('groups_users', schema=None) as batch_op:
+            batch_op.alter_column('group_id',
+                   existing_type=sa.INTEGER(),
+                   nullable=False)
+            batch_op.alter_column('user_id',
+                   existing_type=sa.INTEGER(),
+                   nullable=False)
 
     with op.batch_alter_table('messages', schema=None) as batch_op:
         batch_op.alter_column('date_created',
@@ -97,6 +101,8 @@ def upgrade():
 
 
 def downgrade():
+    connection = op.get_bind()
+
     # ### commands auto generated by Alembic - please adjust! ###
     with op.batch_alter_table('users', schema=None) as batch_op:
         batch_op.alter_column('login_attempts',
@@ -155,13 +161,14 @@ def downgrade():
                existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
                nullable=True)
 
-    with op.batch_alter_table('groups_users', schema=None) as batch_op:
-        batch_op.alter_column('user_id',
-               existing_type=sa.INTEGER(),
-               nullable=True)
-        batch_op.alter_column('group_id',
-               existing_type=sa.INTEGER(),
-               nullable=True)
+    if connection.engine.dialect.name != "mysql":
+        with op.batch_alter_table('groups_users', schema=None) as batch_op:
+            batch_op.alter_column('user_id',
+                   existing_type=sa.INTEGER(),
+                   nullable=True)
+            batch_op.alter_column('group_id',
+                   existing_type=sa.INTEGER(),
+                   nullable=True)
 
     with op.batch_alter_table('forumsread', schema=None) as batch_op:
         batch_op.alter_column('last_read',