From 60f881a53519cfb8b75e71c443d465f5b7c6ef62 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 28 Apr 2022 01:04:54 -0400 Subject: [PATCH] notes on issues; grant schema usage --- readme.md | 4 +++- setup_sql/01_schema.sql | 5 +++++ setup_sql/02_target_info.sql | 2 +- setup_sql/03_build_master_tables.sql | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 6fb688e..28c0e7d 100644 --- a/readme.md +++ b/readme.md @@ -48,7 +48,9 @@ setup * logid (added if missing) issues - - [ ] baseline request json is not depostiing correctly into the sql + - [ ] use sql stored in table instead of pulling from file + - [ ] include building all the route sql as setup step + - [x] baseline request json is not depostiing correctly into the sql - [ ] what if you create a func table but some of the values are null? (orders without quotes) - [x] what if you want certain things like invoice numbers included in the baseline, is a func table necesary? no, just leave fkey null and no table will be setup - [x] baseline needs to populate all columns in sequential order like the scale route diff --git a/setup_sql/01_schema.sql b/setup_sql/01_schema.sql index d1396fd..c41c207 100644 --- a/setup_sql/01_schema.sql +++ b/setup_sql/01_schema.sql @@ -1,4 +1,6 @@ +DROP SCHEMA fc CASCADE; CREATE SCHEMA IF NOT EXISTS fc; +CREATE TABLE fc.dcard AS (SELECT * FROM tpsv.dcard_mapped) WITH DATA; --DROP TABLE IF EXISTS fc.target_meta; CREATE TABLE IF NOT EXISTS fc.target_meta ( @@ -85,6 +87,9 @@ CREATE TABLE fc.perd ( sspr text ); +GRANT USAGE ON SCHEMA fc TO api; +GRANT ALL ON ALL TABLES IN SCHEMA fc TO api; + COPY fc.perd (comp, fsyr, perds, perd, fspr, sdat, edat, drange, capr, ndays, ssyr, sspr) FROM stdin; 93 2008 12 1 0801 2008-01-01 2008-01-31 [2008-01-01,2008-01-31) 0801 31 2008 08 93 2008 12 2 0802 2008-02-01 2008-02-29 [2008-02-01,2008-02-29) 0802 29 2008 09 diff --git a/setup_sql/02_target_info.sql b/setup_sql/02_target_info.sql index df9e3bb..416b66f 100644 --- a/setup_sql/02_target_info.sql +++ b/setup_sql/02_target_info.sql @@ -17,7 +17,7 @@ FROM information_schema.columns WHERE table_name = 'dcard' - AND table_schema = 'tpsv' + AND table_schema = 'fc' ON CONFLICT ON CONSTRAINT target_meta_pk DO UPDATE SET opos = EXCLUDED.opos ,dtype = EXCLUDED.dtype; diff --git a/setup_sql/03_build_master_tables.sql b/setup_sql/03_build_master_tables.sql index a087d54..021d8a8 100644 --- a/setup_sql/03_build_master_tables.sql +++ b/setup_sql/03_build_master_tables.sql @@ -27,7 +27,7 @@ BEGIN FROM fc.target_meta tm WHERE - --only create master tables that don't have date as a foreign key + --only create master tables that have a foreign key (that isn't a date) func IN (SELECT DISTINCT func FROM fc.target_meta WHERE fkey IS NOT NULL AND func IS NOT NULL AND dtype <> 'date') GROUP BY schema