Skip to content

Commit a7b133c

Browse files
committed
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.
1 parent bdc008d commit a7b133c

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

cfgov/v1/migrations/0015_grouppagepermission_index_fix.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,9 @@
33
from django.db import migrations
44

55

6-
# This is a one-off fix to convert an existing unique index on a Wagtail
7-
# table into a unique constraint. See internal Design-and-Content-Team#389.
8-
#
9-
# https://github.com/wagtail/wagtail/blob/b6ba78de814f9bc293e55957ac70d890d950053e/wagtail/models/__init__.py#L3060
10-
table_name = "wagtailcore_grouppagepermission"
11-
12-
13-
index_name = "idx_17388_wagtailcore_grouppagepermission_group_id_16e761a17265"
14-
15-
16-
# "nosec" is used here to suppress Bandit warning about this raw SQL.
17-
# https://bandit.readthedocs.io/en/1.7.6/plugins/b608_hardcoded_sql_expressions.html
18-
sql = f"""
19-
DO $$ BEGIN
20-
IF EXISTS (SELECT FROM pg_indexes WHERE indexname='{index_name}') THEN
21-
DROP INDEX {index_name};
22-
ALTER TABLE {table_name} ADD CONSTRAINT {index_name} UNIQUE(group_id, page_id, permission_type);
23-
END IF;
24-
END $$;
25-
""".strip() # nosec
26-
27-
286
class Migration(migrations.Migration):
297
dependencies = [
308
("v1", "0014_update_ds_links"),
319
]
3210

33-
operations = [
34-
migrations.RunSQL(sql, migrations.RunSQL.noop, elidable=True)
35-
]
11+
operations = []

cfgov/v1/migrations/0033_wagtailsearch_querydailyhits_index_fix.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,6 @@
22

33
from django.db import migrations
44

5-
# This is a one-off fix to convert an existing unique index on a Wagtail
6-
# table into a unique constraint. See internal Design-and-Content-Team#389
7-
# for a description of the problem with a different constraint,
8-
# https://github.com/cfpb/consumerfinance.gov/pull/8066 for the fix this is
9-
# based on.
10-
#
11-
# The mode QueryDailyHits is and its `UNIQUE` constraints are removed in
12-
# wagtail.search.migrations.0008_remove_query_and_querydailyhits_models.py
13-
# in Wagtail 6.0. This migration will prepare our database for the constraint's
14-
# constraint's removal.
15-
16-
table_name = "wagtailsearch_querydailyhits"
17-
index_name = "idx_17496_wagtailsearch_querydailyhits_query_id_4e12c633921cb0c"
18-
unique_together = "query_id, date"
19-
20-
# nosec used here to suppress Bandit warning about this raw SQL.
21-
# https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html
22-
sql = f"""
23-
DO $$ BEGIN
24-
IF EXISTS (SELECT FROM pg_indexes WHERE indexname='{index_name}') THEN
25-
DROP INDEX {index_name};
26-
ALTER TABLE {table_name} ADD CONSTRAINT {index_name} UNIQUE({unique_together});
27-
END IF;
28-
END $$;
29-
""".strip() # nosec B608
30-
315

326
class Migration(migrations.Migration):
337
dependencies = [
@@ -39,5 +13,4 @@ class Migration(migrations.Migration):
3913
]
4014

4115
operations = [
42-
migrations.RunSQL(sql, migrations.RunSQL.noop, elidable=True)
4316
]

0 commit comments

Comments
 (0)