|
@@ -0,0 +1,66 @@
|
|
|
+"""empty message
|
|
|
+
|
|
|
+Revision ID: 5319c9f4b7bc
|
|
|
+Revises: c84b6cdc4e99
|
|
|
+Create Date: 2017-09-22 17:09:35.838584
|
|
|
+
|
|
|
+"""
|
|
|
+
|
|
|
+# revision identifiers, used by Alembic.
|
|
|
+revision = '5319c9f4b7bc'
|
|
|
+down_revision = 'c84b6cdc4e99'
|
|
|
+
|
|
|
+from alembic import op
|
|
|
+import sqlalchemy as sa
|
|
|
+
|
|
|
+
|
|
|
+def upgrade():
|
|
|
+ # ### commands auto generated by Alembic - please adjust! ###
|
|
|
+
|
|
|
+ naming_convention = {
|
|
|
+ "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
|
|
|
+ }
|
|
|
+
|
|
|
+ op.create_table('groups',
|
|
|
+ sa.Column('id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('name', sa.String(), nullable=True),
|
|
|
+ sa.Column('description', sa.String(), nullable=True),
|
|
|
+ sa.PrimaryKeyConstraint('id')
|
|
|
+ )
|
|
|
+ op.create_table('memberships',
|
|
|
+ sa.Column('id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('user_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('group_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('is_creator', sa.Boolean(), nullable=True),
|
|
|
+ sa.Column('is_admin', sa.Boolean(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('id')
|
|
|
+ )
|
|
|
+
|
|
|
+ with op.batch_alter_table(u'access_requests', naming_convention=naming_convention, schema=None) as batch_op:
|
|
|
+ batch_op.add_column(sa.Column('group_id', sa.Integer(), nullable=True))
|
|
|
+ batch_op.create_foreign_key('fk_access_requests_group_id_groups', 'groups', ['group_id'], ['id'])
|
|
|
+
|
|
|
+ with op.batch_alter_table(u'direct_access', naming_convention=naming_convention, schema=None) as batch_op:
|
|
|
+ batch_op.add_column(sa.Column('group_id', sa.Integer(), nullable=True))
|
|
|
+ batch_op.create_foreign_key('fk_direct_access_group_id_groups', 'groups', ['group_id'], ['id'])
|
|
|
+
|
|
|
+ # ### end Alembic commands ###
|
|
|
+
|
|
|
+def downgrade():
|
|
|
+ # ### commands auto generated by Alembic - please adjust! ###
|
|
|
+ naming_convention = {
|
|
|
+ "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
|
|
|
+ }
|
|
|
+ with op.batch_alter_table(u'direct_access', naming_convention=naming_convention, schema=None) as batch_op:
|
|
|
+ batch_op.drop_constraint('fk_direct_access_group_id_groups', type_='foreignkey')
|
|
|
+ batch_op.drop_column('group_id')
|
|
|
+
|
|
|
+ with op.batch_alter_table(u'access_requests', schema=None) as batch_op:
|
|
|
+ batch_op.drop_constraint('fk_access_requests_group_id_groups', type_='foreignkey')
|
|
|
+ batch_op.drop_column('group_id')
|
|
|
+
|
|
|
+ op.drop_table('memberships')
|
|
|
+ op.drop_table('groups')
|
|
|
+ # ### end Alembic commands ###
|