Skip to content

Commit

Permalink
chore: db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
abyrne committed Nov 9, 2023
1 parent 71dedfc commit 420d509
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/migrations/versions/4799661c144e_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""empty message
Revision ID: 4799661c144e
Revises: 7086ad09e884
Create Date: 2023-11-09 17:27:00.506785
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4799661c144e'
down_revision = '7086ad09e884'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('groups',
sa.Column('group_id', sa.BigInteger(), nullable=False),
sa.Column('name', sa.String(length=36), nullable=True),
sa.Column('creator_id', sa.BigInteger(), nullable=True),
sa.Column('owner_id', sa.BigInteger(), nullable=True),
sa.Column('created_on', sa.DateTime(), nullable=True),
sa.Column('deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['creator_id'], ['users.user_id'], name=op.f('fk_groups_creator_id_users')),
sa.ForeignKeyConstraint(['owner_id'], ['users.user_id'], name=op.f('fk_groups_owner_id_users')),
sa.PrimaryKeyConstraint('group_id', name=op.f('pk_groups'))
)
with op.batch_alter_table('groups', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_groups_creator_id'), ['creator_id'], unique=False)
batch_op.create_index(batch_op.f('ix_groups_owner_id'), ['owner_id'], unique=False)

op.create_table('group_memberships',
sa.Column('user_id', sa.BigInteger(), nullable=False),
sa.Column('group_id', sa.BigInteger(), nullable=False),
sa.Column('read', sa.Boolean(), nullable=True),
sa.Column('write', sa.Boolean(), nullable=True),
sa.Column('share_read', sa.Boolean(), nullable=True),
sa.Column('share_write', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['group_id'], ['groups.group_id'], name=op.f('fk_group_memberships_group_id_groups')),
sa.ForeignKeyConstraint(['user_id'], ['users.user_id'], name=op.f('fk_group_memberships_user_id_users')),
sa.PrimaryKeyConstraint('user_id', 'group_id', name=op.f('pk_group_memberships'))
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('group_memberships')
with op.batch_alter_table('groups', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_groups_owner_id'))
batch_op.drop_index(batch_op.f('ix_groups_creator_id'))

op.drop_table('groups')
# ### end Alembic commands ###

0 comments on commit 420d509

Please sign in to comment.