Skip to content

Commit

Permalink
Backfill LMSCourseApplication instance
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Aug 23, 2024
1 parent 6a7af15 commit 2437488
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""LMSCourseApplicationInstance backfill."""

import sqlalchemy as sa
from alembic import op

revision = "9e79650bed37"
down_revision = "e13fb37c96e5"


def upgrade() -> None:
conn = op.get_bind()
conn.execute(
sa.text(
"""
WITH backfill as (
SELECT
"grouping".created,
"grouping".updated,
lms_course.id lms_course_id,
"grouping".application_instance_id
FROM "grouping"
JOIN lms_course on lms_course.h_authority_provided_id = "grouping".authority_provided_id
)
INSERT INTO lms_course_application_instance (
created,
updated,
lms_course_id,
application_instance_id
)
SELECT
created,
updated,
lms_course_id,
application_instance_id
FROM backfill
ON CONFLICT (lms_course_id, application_instance_id) DO NOTHING
"""
)
)


def downgrade() -> None:
pass

0 comments on commit 2437488

Please sign in to comment.