#11 Added enrollment table and relationship between user/couse

This commit is contained in:
2023-04-06 16:19:15 -04:00
parent 12498c2ee8
commit 5beaf2dba4
2 changed files with 66 additions and 7 deletions

View File

@@ -0,0 +1,34 @@
"""Create enrollment table
Revision ID: 093a66f0b581
Revises: 471b4225837e
Create Date: 2023-04-06 16:14:21.262823
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '093a66f0b581'
down_revision = '471b4225837e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('enrollment',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('course_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('user_id', 'course_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('enrollment')
# ### end Alembic commands ###