Add m2m corpus-follower table

This commit is contained in:
Patrick Jentsch
2023-01-23 11:50:12 +01:00
parent 62bd21ad84
commit 97bba2498b
5 changed files with 123 additions and 141 deletions

View File

@ -1,31 +0,0 @@
"""Add corpus_followers table
Revision ID: 4aa88f253dab
Revises: 5b2a6e590166
Create Date: 2023-01-12 14:47:39.492875
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4aa88f253dab'
down_revision = '5b2a6e590166'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'corpus_followers',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('corpus_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['corpus_id'], ['corpora.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('user_id', 'corpus_id')
)
def downgrade():
op.drop_table('corpus_followers')

View File

@ -0,0 +1,36 @@
"""empty message
Revision ID: 5fe6a6c7870c
Revises: 5b2a6e590166
Create Date: 2023-01-23 08:27:10.169454
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5fe6a6c7870c'
down_revision = '5b2a6e590166'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('corpus_follower_associations',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('following_user_id', sa.Integer(), nullable=True),
sa.Column('followed_corpus_id', sa.Integer(), nullable=True),
sa.Column('permissions', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['followed_corpus_id'], ['corpora.id'], ),
sa.ForeignKeyConstraint(['following_user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('corpus_follower_associations')
# ### end Alembic commands ###

View File

@ -1,31 +0,0 @@
"""Add user_followers table
Revision ID: 7d51bc4b6079
Revises: 4aa88f253dab
Create Date: 2023-01-17 12:48:33.261942
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7d51bc4b6079'
down_revision = '4aa88f253dab'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'user_followers',
sa.Column('follower_user_id', sa.Integer(), nullable=False),
sa.Column('followed_user_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['followed_user_id'], ['users.id'], ),
sa.ForeignKeyConstraint(['follower_user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('follower_user_id', 'followed_user_id')
)
def downgrade():
op.drop_table('user_followers')