From f31f0b4cefc583ea5df7111123b67338239154bd Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Mon, 2 Sep 2024 18:14:48 +0200 Subject: [PATCH] Migration for AssignmentRoster --- .../cb5fe6e8dc09_assignment_rosters_table.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lms/migrations/versions/cb5fe6e8dc09_assignment_rosters_table.py diff --git a/lms/migrations/versions/cb5fe6e8dc09_assignment_rosters_table.py b/lms/migrations/versions/cb5fe6e8dc09_assignment_rosters_table.py new file mode 100644 index 0000000000..0704a468f7 --- /dev/null +++ b/lms/migrations/versions/cb5fe6e8dc09_assignment_rosters_table.py @@ -0,0 +1,53 @@ +"""Assignment Rosters table.""" + +import sqlalchemy as sa +from alembic import op + +revision = "cb5fe6e8dc09" +down_revision = "481968561169" + + +def upgrade() -> None: + op.create_table( + "assignment_roster", + 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("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( + ["assignment_id"], + ["assignment.id"], + name=op.f("fk__assignment_roster__assignment_id__assignment"), + ondelete="cascade", + ), + sa.ForeignKeyConstraint( + ["lms_user_id"], + ["lms_user.id"], + name=op.f("fk__assignment_roster__lms_user_id__lms_user"), + ondelete="cascade", + ), + sa.ForeignKeyConstraint( + ["lti_role_id"], + ["lti_role.id"], + name=op.f("fk__assignment_roster__lti_role_id__lti_role"), + ondelete="cascade", + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk__assignment_roster")), + sa.UniqueConstraint( + "assignment_id", + "lms_user_id", + "lti_role_id", + name=op.f("uq__assignment_roster__assignment_id"), + ), + ) + + +def downgrade() -> None: + op.drop_table("assignment_roster")