Browse Source

Squish migrations into one

Alec Nikolas Reiter 7 years ago
parent
commit
4176584b16

+ 0 - 57
migrations/05da2ac3bd49_add_hidden_fields_and_permission.py

@@ -1,57 +0,0 @@
-"""Add hidden fields and permission
-
-Revision ID: 05da2ac3bd49
-Revises: 331500ad355b
-Create Date: 2017-09-03 21:48:30.850960
-
-"""
-import sqlalchemy as sa
-from alembic import op
-
-# revision identifiers, used by Alembic.
-revision = '05da2ac3bd49'
-down_revision = '331500ad355b'
-branch_labels = ()
-depends_on = None
-
-
-def upgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('groups', schema=None) as batch_op:
-        batch_op.add_column(
-            sa.Column('viewhidden', sa.Boolean(), nullable=True)
-        )
-
-    with op.batch_alter_table('groups', schema=None) as batch_op:
-        groups = sa.sql.table(
-            'groups',
-            sa.sql.column('viewhidden'),
-            sa.sql.column('admin'), sa.sql.column('super_mod'), sa.sql.column('mod')
-        )
-        batch_op.execute(
-            groups.update().where(
-                sa.or_(
-                    groups.c.admin == True,
-                    groups.c.mod == True,
-                    groups.c.super_mod == True
-                )
-            ).values(viewhidden=True)
-        )
-        batch_op.execute(
-            groups.update().where(sa.and_(
-                groups.c.admin != True,
-                groups.c.mod != True,
-                groups.c.super_mod != True
-            )).values(viewhidden=False)
-        )
-
-        batch_op.alter_column('viewhidden', existing_type=sa.Boolean(), nullable=False)
-    # ### end Alembic commands ###
-
-
-def downgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('groups', schema=None) as batch_op:
-        batch_op.drop_column('viewhidden')
-
-    # ### end Alembic commands ###

+ 0 - 43
migrations/331500ad355b_make_post_and_topic_hideable_models.py

@@ -1,43 +0,0 @@
-"""Make post and topic hideable models
-
-Revision ID: 331500ad355b
-Revises:
-Create Date: 2017-09-03 17:03:06.460391
-
-"""
-from alembic import op
-import sqlalchemy as sa
-from flaskbb.utils.database import UTCDateTime
-
-
-# revision identifiers, used by Alembic.
-revision = '331500ad355b'
-down_revision = None
-branch_labels = ('default',)
-depends_on = None
-
-
-def upgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('posts', schema=None) as batch_op:
-        batch_op.add_column(sa.Column('hidden', sa.Boolean(), nullable=True))
-        batch_op.add_column(sa.Column('hidden_at', UTCDateTime(timezone=True), nullable=True))
-
-    with op.batch_alter_table('topics', schema=None) as batch_op:
-        batch_op.add_column(sa.Column('hidden', sa.Boolean(), nullable=True))
-        batch_op.add_column(sa.Column('hidden_at', UTCDateTime(timezone=True), nullable=True))
-
-    # ### end Alembic commands ###
-
-
-def downgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('topics', schema=None) as batch_op:
-        batch_op.drop_column('hidden_at')
-        batch_op.drop_column('hidden')
-
-    with op.batch_alter_table('posts', schema=None) as batch_op:
-        batch_op.drop_column('hidden_at')
-        batch_op.drop_column('hidden')
-
-    # ### end Alembic commands ###

+ 0 - 59
migrations/63eabbb0e837_add_makehidden_permission.py

@@ -1,59 +0,0 @@
-"""Add makehidden permission
-
-Revision ID: 63eabbb0e837
-Revises: 05da2ac3bd49
-Create Date: 2017-09-03 23:43:54.316625
-
-"""
-from alembic import op
-import sqlalchemy as sa
-
-
-# revision identifiers, used by Alembic.
-revision = '63eabbb0e837'
-down_revision = '05da2ac3bd49'
-branch_labels = ()
-depends_on = None
-
-
-def upgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('groups', schema=None) as batch_op:
-        batch_op.add_column(
-            sa.Column('makehidden', sa.Boolean(), nullable=True)
-        )
-
-    with op.batch_alter_table('groups', schema=None) as batch_op:
-        groups = sa.sql.table(
-            'groups',
-            sa.sql.column('makehidden'),
-            sa.sql.column('admin'), sa.sql.column('super_mod'), sa.sql.column('mod')
-        )
-        batch_op.execute(
-            groups.update().where(
-                sa.or_(
-                    groups.c.admin == True,
-                    groups.c.mod == True,
-                    groups.c.super_mod == True
-                )
-            ).values(makehidden=True)
-        )
-        batch_op.execute(
-            groups.update().where(sa.and_(
-                groups.c.admin != True,
-                groups.c.mod != True,
-                groups.c.super_mod != True
-            )).values(makehidden=False)
-        )
-
-        batch_op.alter_column('makehidden', existing_type=sa.Boolean(), nullable=False)
-
-    # ### end Alembic commands ###
-
-
-def downgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('groups', schema=None) as batch_op:
-        batch_op.drop_column('makehidden')
-
-    # ### end Alembic commands ###

+ 85 - 0
migrations/d0ffadc3ea48_add_hidden_columns.py

@@ -0,0 +1,85 @@
+"""Add hidden columns
+
+Revision ID: d0ffadc3ea48
+Revises:
+Create Date: 2017-09-04 15:19:38.519991
+
+"""
+from alembic import op
+import sqlalchemy as sa
+import flaskbb
+
+
+# revision identifiers, used by Alembic.
+revision = 'd0ffadc3ea48'
+down_revision = None
+branch_labels = ('default',)
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('groups', schema=None) as batch_op:
+        batch_op.add_column(sa.Column('makehidden', sa.Boolean(), nullable=True))
+        batch_op.add_column(sa.Column('viewhidden', sa.Boolean(), nullable=True))
+
+    with op.batch_alter_table('groups', schema=None) as batch_op:
+        groups = sa.sql.table(
+            'groups',
+            sa.sql.column('viewhidden'), sa.sql.column('makehidden'),
+            sa.sql.column('admin'), sa.sql.column('super_mod'), sa.sql.column('mod')
+        )
+        batch_op.execute(
+            groups.update().where(
+                sa.or_(
+                    groups.c.admin == True,
+                    groups.c.mod == True,
+                    groups.c.super_mod == True
+                )
+            ).values(viewhidden=True, makehidden=True)
+        )
+        batch_op.execute(
+            groups.update().where(sa.and_(
+                groups.c.admin != True,
+                groups.c.mod != True,
+                groups.c.super_mod != True
+            )).values(viewhidden=False, makehidden=False)
+        )
+
+        batch_op.alter_column('viewhidden', existing_type=sa.Boolean(), nullable=False)
+        batch_op.alter_column('makehidden', existing_type=sa.Boolean(), nullable=False)
+
+    with op.batch_alter_table('posts', schema=None) as batch_op:
+        batch_op.add_column(sa.Column('hidden', sa.Boolean(), nullable=True))
+        batch_op.add_column(sa.Column('hidden_at', flaskbb.utils.database.UTCDateTime(timezone=True), nullable=True))
+        batch_op.add_column(sa.Column('hidden_by_id', sa.Integer(), nullable=True))
+        batch_op.create_foreign_key('fk_Post_hidden_by', 'users', ['hidden_by_id'], ['id'])
+
+    with op.batch_alter_table('topics', schema=None) as batch_op:
+        batch_op.add_column(sa.Column('hidden', sa.Boolean(), nullable=True))
+        batch_op.add_column(sa.Column('hidden_at', flaskbb.utils.database.UTCDateTime(timezone=True), nullable=True))
+        batch_op.add_column(sa.Column('hidden_by_id', sa.Integer(), nullable=True))
+        batch_op.create_foreign_key('fk_Topic_hidden_by', 'users', ['hidden_by_id'], ['id'])
+
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('topics', schema=None) as batch_op:
+        batch_op.drop_constraint('fk_Topic_hidden_by', type_='foreignkey')
+        batch_op.drop_column('hidden_by_id')
+        batch_op.drop_column('hidden_at')
+        batch_op.drop_column('hidden')
+
+    with op.batch_alter_table('posts', schema=None) as batch_op:
+        batch_op.drop_constraint('fk_Post_hidden_by', type_='foreignkey')
+        batch_op.drop_column('hidden_by_id')
+        batch_op.drop_column('hidden_at')
+        batch_op.drop_column('hidden')
+
+    with op.batch_alter_table('groups', schema=None) as batch_op:
+        batch_op.drop_column('viewhidden')
+        batch_op.drop_column('makehidden')
+
+    # ### end Alembic commands ###

+ 0 - 42
migrations/fd6ed1fd7d1a_add_hidden_by_column.py

@@ -1,42 +0,0 @@
-"""Add hidden_by column
-
-Revision ID: fd6ed1fd7d1a
-Revises: 63eabbb0e837
-Create Date: 2017-09-04 13:04:52.973752
-
-"""
-from alembic import op
-import sqlalchemy as sa
-
-
-# revision identifiers, used by Alembic.
-revision = 'fd6ed1fd7d1a'
-down_revision = '63eabbb0e837'
-branch_labels = ()
-depends_on = None
-
-
-def upgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('posts', schema=None) as batch_op:
-        batch_op.add_column(sa.Column('hidden_by_id', sa.Integer(), nullable=True))
-        batch_op.create_foreign_key('fk_Post_hidden_by', 'users', ['hidden_by_id'], ['id'])
-
-    with op.batch_alter_table('topics', schema=None) as batch_op:
-        batch_op.add_column(sa.Column('hidden_by_id', sa.Integer(), nullable=True))
-        batch_op.create_foreign_key('fk_Topic_hidden_by', 'users', ['hidden_by_id'], ['id'])
-
-    # ### end Alembic commands ###
-
-
-def downgrade():
-    # ### commands auto generated by Alembic - please adjust! ###
-    with op.batch_alter_table('topics', schema=None) as batch_op:
-        batch_op.drop_constraint('fk_Topic_hidden_by', type_='foreignkey')
-        batch_op.drop_column('hidden_by_id')
-
-    with op.batch_alter_table('posts', schema=None) as batch_op:
-        batch_op.drop_constraint('fk_Post_hidden_by', type_='foreignkey')
-        batch_op.drop_column('hidden_by_id')
-
-    # ### end Alembic commands ###