Skip to content

Commit

Permalink
Migration to create CourseRoster
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Aug 29, 2024
1 parent 4146044 commit 77769e8
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions lms/migrations/versions/2f05ff66ec2e_courseroster_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""CourseRoster table."""

import sqlalchemy as sa
from alembic import op

revision = "2f05ff66ec2e"
down_revision = "b97080de93bc"


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"course_roster",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("lms_course_id", sa.Integer(), nullable=False),
sa.Column("lms_user_id", sa.Integer(), nullable=False),
sa.Column("lti_role_id", sa.Integer(), nullable=False),
sa.Column("active", sa.Boolean(), nullable=False),
sa.Column(
"created", sa.DateTime(), server_default=sa.text("now()"), nullable=False
),
sa.Column(
"updated", sa.DateTime(), server_default=sa.text("now()"), nullable=False
),
sa.ForeignKeyConstraint(
["lms_course_id"],
["lms_course.id"],
name=op.f("fk__course_roster__lms_course_id__lms_course"),
ondelete="cascade",
),
sa.ForeignKeyConstraint(
["lms_user_id"],
["lms_user.id"],
name=op.f("fk__course_roster__lms_user_id__lms_user"),
ondelete="cascade",
),
sa.ForeignKeyConstraint(
["lti_role_id"],
["lti_role.id"],
name=op.f("fk__course_roster__lti_role_id__lti_role"),
ondelete="cascade",
),
sa.PrimaryKeyConstraint("id", name=op.f("pk__course_roster")),
sa.UniqueConstraint(
"lms_course_id",
"lms_user_id",
"lti_role_id",
name=op.f("uq__course_roster__lms_course_id"),
),
)


def downgrade() -> None:
op.drop_table("course_roster")

0 comments on commit 77769e8

Please sign in to comment.