-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1191 from Amsterdam/improvement/azure-db
Updated query to remove tables
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
app/apps/cases/migrations/0025_remove_unused_tables_azure.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,65 @@ | ||
# Generated by Django 3.2.13 on 2024-02-12 10:14 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("cases", "0024_alter_default_column_ids_azure"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
sql=""" | ||
DO $$ | ||
BEGIN | ||
-- Delete individual tables if they exist | ||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'auth_user') THEN | ||
DROP TABLE public.auth_user CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'auth_user_groups') THEN | ||
DROP TABLE public.auth_user_groups CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'auth_user_user_permissions') THEN | ||
DROP TABLE public.auth_user_user_permissions CASCADE; | ||
END IF; | ||
-- Delete sequences if they exist | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'auth_user_groups_id_seq') THEN | ||
DROP SEQUENCE public.auth_user_groups_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'auth_user_id_seq') THEN | ||
DROP SEQUENCE public.auth_user_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'auth_user_user_permissions_id_seq') THEN | ||
DROP SEQUENCE public.auth_user_user_permissions_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'events_event_id_seq') THEN | ||
DROP SEQUENCE public.events_event_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'cases_caseteam_id_seq') THEN | ||
DROP SEQUENCE public.cases_caseteam_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'schedules_scheduletype_id_seq') THEN | ||
DROP SEQUENCE public.schedules_scheduletype_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'workflow_task_id_seq') THEN | ||
DROP SEQUENCE public.workflow_task_id_seq CASCADE; | ||
END IF; | ||
IF EXISTS (SELECT 1 FROM information_schema.sequences WHERE sequence_schema = 'public' AND sequence_name = 'workflow_workflow_id_seq') THEN | ||
DROP SEQUENCE public.workflow_workflow_id_seq CASCADE; | ||
END IF; | ||
END $$; | ||
""" | ||
) | ||
] |