From 4f2f4e2dc98387e6e5323a91543328f63fa68e1e Mon Sep 17 00:00:00 2001 From: James Person Date: Wed, 28 Aug 2024 14:51:05 -0400 Subject: [PATCH] Keep v1_1_1 files, but disable it everywhere --- backend/dissemination/api_versions.py | 16 +--------------- .../management/commands/create_api_views.py | 1 - .../management/commands/materialized_views.py | 3 --- backend/docker-compose-web.yml | 2 +- backend/docker-compose.yml | 2 +- terraform/shared/modules/env/postgrest.tf | 2 +- 6 files changed, 4 insertions(+), 22 deletions(-) diff --git a/backend/dissemination/api_versions.py b/backend/dissemination/api_versions.py index 574f015b0f..56e209f9c5 100644 --- a/backend/dissemination/api_versions.py +++ b/backend/dissemination/api_versions.py @@ -7,7 +7,7 @@ # These are API versions we want live. live = { - "dissemination": ["api_v1_0_3", "api_v1_1_0", "api_v1_1_1"], + "dissemination": ["api_v1_0_3", "api_v1_1_0"], "support": ["admin_api_v1_1_0"], } @@ -47,20 +47,6 @@ def exec_sql(location, version, filename): curs.execute(sql) -def create_materialized_view(location): - """ - Create or recreate the dissemination_combined materialized view. - We only want this done once on startup, regardless of the API version. - """ - conn = connection(get_conn_string()) - conn.autocommit = True - with conn.cursor() as curs: - path = f"{location}/sql/create_materialized_views.sql" - logger.info("EXEC SQL create_materialized_views.sql") - sql = open(path, "r").read() - curs.execute(sql) - - def create_views(location, version): exec_sql(location, version, "create_views.sql") diff --git a/backend/dissemination/management/commands/create_api_views.py b/backend/dissemination/management/commands/create_api_views.py index 4db39d481e..105b87a780 100644 --- a/backend/dissemination/management/commands/create_api_views.py +++ b/backend/dissemination/management/commands/create_api_views.py @@ -8,7 +8,6 @@ class Command(BaseCommand): """ def handle(self, *args, **kwargs): - api_versions.create_materialized_view("dissemination") api_versions.create_functions("dissemination") api_versions.create_functions("support") api_versions.create_live_views("dissemination") diff --git a/backend/dissemination/management/commands/materialized_views.py b/backend/dissemination/management/commands/materialized_views.py index 11c0b8ab14..67acc95b5d 100644 --- a/backend/dissemination/management/commands/materialized_views.py +++ b/backend/dissemination/management/commands/materialized_views.py @@ -15,10 +15,7 @@ def add_arguments(self, parser): def handle(self, *args, **options): path = "dissemination/sql" if options["create"]: - # Other API views may rely on the materialized view. So, drop and recreate them. - api_versions.drop_live_views("dissemination") api_versions.exec_sql_at_path(path, "create_materialized_views.sql") - api_versions.create_live_views("dissemination") elif options["drop"]: api_versions.exec_sql_at_path(path, "drop_materialized_views.sql") elif options["refresh"]: diff --git a/backend/docker-compose-web.yml b/backend/docker-compose-web.yml index f7f9c6017e..98deabef2e 100644 --- a/backend/docker-compose-web.yml +++ b/backend/docker-compose-web.yml @@ -99,7 +99,7 @@ services: PGRST_OPENAPI_SERVER_PROXY_URI: http://127.0.0.1:3000 PGRST_DB_ANON_ROLE: anon # See https://postgrest.org/en/stable/references/api/schemas.html#multiple-schemas for multiple schemas - PGRST_DB_SCHEMAS: "api_v1_0_3, api_v1_1_0, api_v1_1_1, admin_api_v1_1_0" + PGRST_DB_SCHEMAS: "api_v1_0_3, api_v1_1_0, admin_api_v1_1_0" PGRST_JWT_SECRET: ${PGRST_JWT_SECRET:-32_chars_fallback_secret_testing} # Fallback value for testing environments depends_on: db: diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index ace79bc281..f8ee53cada 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -126,7 +126,7 @@ services: PGRST_OPENAPI_SERVER_PROXY_URI: http://127.0.0.1:3000 PGRST_DB_ANON_ROLE: anon # See https://postgrest.org/en/stable/references/api/schemas.html#multiple-schemas for multiple schemas - PGRST_DB_SCHEMAS: "api_v1_0_3, api_v1_1_0, api_v1_1_1, admin_api_v1_1_0" + PGRST_DB_SCHEMAS: "api_v1_0_3, api_v1_1_0, admin_api_v1_1_0" PGRST_JWT_SECRET: ${PGRST_JWT_SECRET:-32_chars_fallback_secret_testing} # Fallback value for testing environments # Enable this to inspect the DB plans for queries via EXPLAIN PGRST_DB_PLAN_ENABLED: ${PGRST_DB_PLAN_ENABLED:-false} diff --git a/terraform/shared/modules/env/postgrest.tf b/terraform/shared/modules/env/postgrest.tf index 7cb705c586..0d0c4d7b69 100644 --- a/terraform/shared/modules/env/postgrest.tf +++ b/terraform/shared/modules/env/postgrest.tf @@ -32,7 +32,7 @@ resource "cloudfoundry_app" "postgrest" { environment = { PGRST_DB_URI : cloudfoundry_service_key.postgrest.credentials.uri - PGRST_DB_SCHEMAS : "api_v1_0_3,api_v1_1_0,api_v1_1_1,admin_api_v1_1_0" + PGRST_DB_SCHEMAS : "api_v1_0_3,api_v1_1_0,admin_api_v1_1_0" PGRST_DB_ANON_ROLE : "anon" PGRST_JWT_SECRET : var.pgrst_jwt_secret PGRST_DB_MAX_ROWS : 20000