From a7b133c93d93ae356c4532b0332788410f8b89d3 Mon Sep 17 00:00:00 2001 From: Andy Chosak Date: Sat, 28 Dec 2024 16:38:32 -0500 Subject: [PATCH] Temporarily make migrations SQLite-compatible These migrations include PostgreSQL-specific syntax and will not run properly against SQLite. This commit temporarily comments them out. A preferred solution is to squash these migrations away, which is proposed in consumerfinance.gov #8701. --- .../0015_grouppagepermission_index_fix.py | 26 +----------------- ..._wagtailsearch_querydailyhits_index_fix.py | 27 ------------------- 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/cfgov/v1/migrations/0015_grouppagepermission_index_fix.py b/cfgov/v1/migrations/0015_grouppagepermission_index_fix.py index 1758fe0844f..260b8e382d3 100644 --- a/cfgov/v1/migrations/0015_grouppagepermission_index_fix.py +++ b/cfgov/v1/migrations/0015_grouppagepermission_index_fix.py @@ -3,33 +3,9 @@ from django.db import migrations -# This is a one-off fix to convert an existing unique index on a Wagtail -# table into a unique constraint. See internal Design-and-Content-Team#389. -# -# https://github.com/wagtail/wagtail/blob/b6ba78de814f9bc293e55957ac70d890d950053e/wagtail/models/__init__.py#L3060 -table_name = "wagtailcore_grouppagepermission" - - -index_name = "idx_17388_wagtailcore_grouppagepermission_group_id_16e761a17265" - - -# "nosec" is used here to suppress Bandit warning about this raw SQL. -# https://bandit.readthedocs.io/en/1.7.6/plugins/b608_hardcoded_sql_expressions.html -sql = f""" -DO $$ BEGIN - IF EXISTS (SELECT FROM pg_indexes WHERE indexname='{index_name}') THEN - DROP INDEX {index_name}; - ALTER TABLE {table_name} ADD CONSTRAINT {index_name} UNIQUE(group_id, page_id, permission_type); - END IF; -END $$; -""".strip() # nosec - - class Migration(migrations.Migration): dependencies = [ ("v1", "0014_update_ds_links"), ] - operations = [ - migrations.RunSQL(sql, migrations.RunSQL.noop, elidable=True) - ] + operations = [] diff --git a/cfgov/v1/migrations/0033_wagtailsearch_querydailyhits_index_fix.py b/cfgov/v1/migrations/0033_wagtailsearch_querydailyhits_index_fix.py index 6d71f3fdea7..cc37265001e 100644 --- a/cfgov/v1/migrations/0033_wagtailsearch_querydailyhits_index_fix.py +++ b/cfgov/v1/migrations/0033_wagtailsearch_querydailyhits_index_fix.py @@ -2,32 +2,6 @@ from django.db import migrations -# This is a one-off fix to convert an existing unique index on a Wagtail -# table into a unique constraint. See internal Design-and-Content-Team#389 -# for a description of the problem with a different constraint, -# https://github.com/cfpb/consumerfinance.gov/pull/8066 for the fix this is -# based on. -# -# The mode QueryDailyHits is and its `UNIQUE` constraints are removed in -# wagtail.search.migrations.0008_remove_query_and_querydailyhits_models.py -# in Wagtail 6.0. This migration will prepare our database for the constraint's -# constraint's removal. - -table_name = "wagtailsearch_querydailyhits" -index_name = "idx_17496_wagtailsearch_querydailyhits_query_id_4e12c633921cb0c" -unique_together = "query_id, date" - -# nosec used here to suppress Bandit warning about this raw SQL. -# https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html -sql = f""" -DO $$ BEGIN - IF EXISTS (SELECT FROM pg_indexes WHERE indexname='{index_name}') THEN - DROP INDEX {index_name}; - ALTER TABLE {table_name} ADD CONSTRAINT {index_name} UNIQUE({unique_together}); - END IF; -END $$; -""".strip() # nosec B608 - class Migration(migrations.Migration): dependencies = [ @@ -39,5 +13,4 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunSQL(sql, migrations.RunSQL.noop, elidable=True) ]