From 1c5b17daa07af64c364ee7fa547b15ab7f509684 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 12 Jul 2021 15:34:50 -0400 Subject: [PATCH] update pool component to reset the log file and sequence for a new forecast --- build/build_pool.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build/build_pool.sql b/build/build_pool.sql index 11b49b4..6a4392b 100644 --- a/build/build_pool.sql +++ b/build/build_pool.sql @@ -1,5 +1,11 @@ BEGIN; +--only do this when starting fresh +TRUNCATE TABLE rlarp.osm_pool; +TRUNCATE TABLE rlarp.osm_log CASCADE; +ALTER SEQUENCE rlarp.osm_log_id_seq RESTART 1; + + DROP TABLE IF EXISTS rlarp.osm_pool_stage; CREATE TABLE rlarp.osm_pool_stage AS ( @@ -49,7 +55,7 @@ repc AS ( SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') <> '' ) ,logload AS ( - INSERT INTO rlarp.osm_log (doc) SELECT jsonb_build_object('user',current_user,'tag','merge actuals','type','build_pool','stamp',current_timestamp,'source','top level','message','don''t undo') RETURNING * + INSERT INTO rlarp.osm_log (doc) SELECT jsonb_build_object('user',current_user,'tag','1+11','type','build_pool','stamp',current_timestamp,'source','top level','message','don''t undo') RETURNING * ) SELECT fspr @@ -171,6 +177,7 @@ FROM --LIMIT 100 ) WITH DATA; + INSERT INTO rlarp.osm_pool SELECT * FROM rlarp.osm_pool_stage; --CREATE INDEX osm_qr ON rlarp.osm_pool(quota_rep_descr, bill_cust_descr, ship_cust_descr);