diff --git a/alter-scripts/alter-1.42.py b/alter-scripts/alter-1.42.py index 7d2b1331..5b29bd4f 100644 --- a/alter-scripts/alter-1.42.py +++ b/alter-scripts/alter-1.42.py @@ -75,8 +75,23 @@ def insert_colleges(clgdata): for org_id, lvl in clgdata.items(): execute(f""" INSERT INTO college (id, level, org_id, updated_by, updated_at, created_by, created_at) - VALUES ('{uuid.uuid4()}', '{lvl}', '{org_id}', '{user_id}', NOW(), '{user_id}', NOW()) + VALUES ('{uuid.uuid4()}', '{lvl}', '{org_id}', '{user_id}',UTC_TIMESTAMP(), '{user_id}', UTC_TIMESTAMP()) """) + + execute(f""" + INSERT INTO college (id, level, org_id, updated_by, updated_at, created_by, created_at) + SELECT + UUID(), + 0 AS level, + org.id AS org_id, + '{user_id}', + UTC_TIMESTAMP(), + '{user_id}', + UTC_TIMESTAMP() + FROM organization AS org + WHERE org.org_type = '{OrganizationType.COLLEGE.value}' + AND org.id NOT IN (SELECT org_id FROM college); + """) return @@ -84,4 +99,4 @@ def insert_colleges(clgdata): data = clg_levels_check() delete_colleges() insert_colleges(data) - execute("UPDATE system_setting SET value = '1.42', updated_at = now() WHERE `key` = 'db.version';") + # execute("UPDATE system_setting SET value = '1.42', updated_at = now() WHERE `key` = 'db.version';")