Skip to content

Commit

Permalink
Migration to crate LMSUserAssignmentMembership
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Oct 7, 2024
1 parent b58d7f7 commit 3261289
Showing 1 changed file with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""Create LMSUserAssignmentMembership."""

import sqlalchemy as sa
from alembic import op

revision = "712c4c9a4e2e"
down_revision = "aea9bbeee574"


def upgrade() -> None:
op.create_table(
"lms_user_assignment_membership",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("assignment_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("lti_v11_lis_result_sourcedid", sa.String(), nullable=True),
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(
["assignment_id"],
["assignment.id"],
name=op.f("fk__lms_user_assignment_membership__assignment_id__assignment"),
ondelete="cascade",
),
sa.ForeignKeyConstraint(
["lms_user_id"],
["lms_user.id"],
name=op.f("fk__lms_user_assignment_membership__lms_user_id__lms_user"),
ondelete="cascade",
),
sa.ForeignKeyConstraint(
["lti_role_id"],
["lti_role.id"],
name=op.f("fk__lms_user_assignment_membership__lti_role_id__lti_role"),
ondelete="cascade",
),
sa.PrimaryKeyConstraint("id", name=op.f("pk__lms_user_assignment_membership")),
sa.UniqueConstraint(
"assignment_id",
"lms_user_id",
"lti_role_id",
name=op.f("uq__lms_user_assignment_membership__assignment_id"),
),
)
op.create_index(
op.f("ix__lms_user_assignment_membership_assignment_id"),
"lms_user_assignment_membership",
["assignment_id"],
unique=False,
)
op.create_index(
op.f("ix__lms_user_assignment_membership_lms_user_id"),
"lms_user_assignment_membership",
["lms_user_id"],
unique=False,
)
op.create_index(
op.f("ix__lms_user_assignment_membership_lti_role_id"),
"lms_user_assignment_membership",
["lti_role_id"],
unique=False,
)


def downgrade() -> None:
op.drop_index(
op.f("ix__lms_user_assignment_membership_lti_role_id"),
table_name="lms_user_assignment_membership",
)
op.drop_index(
op.f("ix__lms_user_assignment_membership_lms_user_id"),
table_name="lms_user_assignment_membership",
)
op.drop_index(
op.f("ix__lms_user_assignment_membership_assignment_id"),
table_name="lms_user_assignment_membership",
)
op.drop_table("lms_user_assignment_membership")

0 comments on commit 3261289

Please sign in to comment.