From a2a1bb489187b90ec8aeeb0f72585d3806a8d76d Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Mon, 5 Aug 2024 13:06:10 +0200 Subject: [PATCH] Migration for assignment.course_id --- ...4a5b_add_assignment_course_relationship.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lms/migrations/versions/18109b584a5b_add_assignment_course_relationship.py diff --git a/lms/migrations/versions/18109b584a5b_add_assignment_course_relationship.py b/lms/migrations/versions/18109b584a5b_add_assignment_course_relationship.py new file mode 100644 index 0000000000..d69e5117f6 --- /dev/null +++ b/lms/migrations/versions/18109b584a5b_add_assignment_course_relationship.py @@ -0,0 +1,25 @@ +"""Add assignment course relationship.""" + +import sqlalchemy as sa +from alembic import op + +revision = "18109b584a5b" +down_revision = "d8d33d882b88" + + +def upgrade() -> None: + op.add_column("assignment", sa.Column("course_id", sa.Integer(), nullable=True)) + op.create_foreign_key( + op.f("fk__assignment__course_id__grouping"), + "assignment", + "grouping", + ["course_id"], + ["id"], + ) + + +def downgrade() -> None: + op.drop_constraint( + op.f("fk__assignment__course_id__grouping"), "assignment", type_="foreignkey" + ) + op.drop_column("assignment", "course_id")