diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/base.sql b/backend/dissemination/api/api_historic_v0_1_0_alpha/base.sql deleted file mode 100644 index 37e9d7347f..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/base.sql +++ /dev/null @@ -1,5 +0,0 @@ -begin; -select 1; -commit; - -notify pgrst, 'reload schema'; diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/create_functions.sql b/backend/dissemination/api/api_historic_v0_1_0_alpha/create_functions.sql deleted file mode 100644 index 37e9d7347f..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/create_functions.sql +++ /dev/null @@ -1,5 +0,0 @@ -begin; -select 1; -commit; - -notify pgrst, 'reload schema'; diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/create_schema.sql b/backend/dissemination/api/api_historic_v0_1_0_alpha/create_schema.sql deleted file mode 100644 index 127b6b4319..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/create_schema.sql +++ /dev/null @@ -1,42 +0,0 @@ --- This schema is handled external to the app. --- Why? --- It relies on static tables that are loaded before the app exists. --- Therefore, we assume those tables are loaded. Or, mostly assume. --- This grants permissions, nothing more. - -begin; - -do -$$ -begin - -- If it exists, grant permissions. - if exists (select schema_name from information_schema.schemata where schema_name = 'api_historic_v0_1_0_alpha') then - -- Grant access to tables and views - alter default privileges - in schema api_historic_v0_1_0_alpha - grant select - -- this includes views - on tables - to api_fac_gov; - - -- Grant access to sequences, if we have them - grant usage on schema api_historic_v0_1_0_alpha to api_fac_gov; - grant select, usage on all sequences in schema api_historic_v0_1_0_alpha to api_fac_gov; - alter default privileges - in schema api_historic_v0_1_0_alpha - grant select, usage - on sequences - to api_fac_gov; - - GRANT SELECT ON ALL TABLES IN SCHEMA api_historic_v0_1_0_alpha TO api_fac_gov; - end if; -end -$$ -; - -select 1; - -commit; - -notify pgrst, 'reload schema'; - diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/create_views.sql b/backend/dissemination/api/api_historic_v0_1_0_alpha/create_views.sql deleted file mode 100644 index 37e9d7347f..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/create_views.sql +++ /dev/null @@ -1,5 +0,0 @@ -begin; -select 1; -commit; - -notify pgrst, 'reload schema'; diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/drop_schema.sql b/backend/dissemination/api/api_historic_v0_1_0_alpha/drop_schema.sql deleted file mode 100644 index 37e9d7347f..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/drop_schema.sql +++ /dev/null @@ -1,5 +0,0 @@ -begin; -select 1; -commit; - -notify pgrst, 'reload schema'; diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/drop_views.sql b/backend/dissemination/api/api_historic_v0_1_0_alpha/drop_views.sql deleted file mode 100644 index 37e9d7347f..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/drop_views.sql +++ /dev/null @@ -1,5 +0,0 @@ -begin; -select 1; -commit; - -notify pgrst, 'reload schema'; diff --git a/backend/dissemination/api/api_historic_v0_1_0_alpha/views.py b/backend/dissemination/api/api_historic_v0_1_0_alpha/views.py deleted file mode 100644 index 993dd3be76..0000000000 --- a/backend/dissemination/api/api_historic_v0_1_0_alpha/views.py +++ /dev/null @@ -1,49 +0,0 @@ -schema = "api_historic_v0_1_0_alpha" -prefix = "census_" - -tables = { - "agency": (16, 22), - "captext": (19, 22), - "captext_formatted": (19, 22), - "cfda": (16, 22), - "cpas": (16, 22), - "duns": (16, 22), - "eins": (16, 22), - "findings": (16, 22), - "findingstext": (19, 22), - "findingstext_formatted": (19, 22), - "gen": (16, 22), - "notes": (19, 22), - "passthrough": (16, 22), - "revisions": (19, 22), - "ueis": (22, 22), -} - - -def just_table_names(lot): - return list(tables.keys()) - - -def generate_views(tbs): - print("begin;\n") - for t, rng in tbs.items(): - # Range is exclusive on the second value - for v in range(rng[0], rng[1] + 1): - print(f"create view {schema}.{t}{v} as") - print("\tselect *") - print(f"\tfrom {prefix}{t}{v}") - print(f"\torder by {prefix}{t}{v}.id") - print(";\n") - print("commit;") - print("notify pgrst, 'reload schema';") - - -if __name__ in "__main__": - generate_views(tables) - -# (define (generate-drops lot) -# (printf "begin;~n~n") -# (for ([t lot]) -# (printf "drop table if exists ~a.~a;~n" schema t)) -# (printf "commit;~n") -# (printf "notify pgrst, 'reload schema';~n"))