-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add get_org_from_ccx_course_url function
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tutoraspects/templates/aspects/apps/aspects/migrations/alembic/versions/0033_ccx_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Create the get_org_from_ccx_course_url function to support CCX courses | ||
""" | ||
from alembic import op | ||
|
||
|
||
revision = "0033" | ||
down_revision = "0032" | ||
branch_labels = None | ||
depends_on = None | ||
on_cluster = " ON CLUSTER '{{CLICKHOUSE_CLUSTER_NAME}}' " if "{{CLICKHOUSE_CLUSTER_NAME}}" else "" | ||
|
||
def upgrade(): | ||
op.execute( | ||
f""" | ||
CREATE OR REPLACE FUNCTION get_org_from_ccx_course_url {on_cluster} | ||
AS ( | ||
course_url) -> | ||
nullIf(EXTRACT(course_url, 'ccx-v1:([a-zA-Z0-9]*)'), ''); | ||
""" | ||
) | ||
|
||
|
||
|
||
def downgrade(): | ||
op.execute("DROP FUNCTION IF EXISTS get_org_from_ccx_course_url;") |