Skip to content

Commit

Permalink
Keep v1_1_1 files, but disable it everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
jperson1 committed Aug 28, 2024
1 parent 44d4933 commit 4f2f4e2
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 22 deletions.
16 changes: 1 addition & 15 deletions backend/dissemination/api_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}

Expand Down Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
2 changes: 1 addition & 1 deletion backend/docker-compose-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion terraform/shared/modules/env/postgrest.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f2f4e2

Please sign in to comment.