put sample data table in separate file and use target table in new table creation

This commit is contained in:
Paul Trowbridge 2022-05-13 13:35:50 -04:00
parent 4ae9a5becd
commit 898593c3a8
3 changed files with 2 additions and 2 deletions

1
setup_sql/01_sample.sql Normal file
View File

@ -0,0 +1 @@
CREATE TABLE fc.dcard AS (SELECT * FROM tpsv.dcard_mapped) WITH DATA;

View File

@ -1,6 +1,5 @@
DROP SCHEMA fc CASCADE; DROP SCHEMA fc CASCADE;
CREATE SCHEMA IF NOT EXISTS fc; 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; --DROP TABLE IF EXISTS fc.target_meta;
CREATE TABLE IF NOT EXISTS fc.target_meta ( CREATE TABLE IF NOT EXISTS fc.target_meta (

View File

@ -36,7 +36,7 @@ BEGIN
--HAVING --HAVING
-- string_agg(cname,', ') FILTER (WHERE fkey = func) <> '' -- string_agg(cname,', ') FILTER (WHERE fkey = func) <> ''
loop loop
INSERT INTO fc.sql SELECT f.func, f.ddl ON CONFLICT ON CONSTRAINT sql_pkey DO UPDATE SET t = EXCLUDED.t; INSERT INTO fc.sql SELECT _target_table, f.func, f.ddl ON CONFLICT ON CONSTRAINT sql_pkey DO UPDATE SET t = EXCLUDED.t;
EXECUTE format('%s',f.ddl); EXECUTE format('%s',f.ddl);
EXECUTE format('%s',f.pop); EXECUTE format('%s',f.pop);
EXECUTE format('%s',f.fk); EXECUTE format('%s',f.fk);