accomodate history defintion of parse map
This commit is contained in:
parent
ad2a7ed68d
commit
f23da6f5ec
@ -51,7 +51,8 @@ CREATE TABLE tps.map_rm (
|
|||||||
srce text NOT NULL,
|
srce text NOT NULL,
|
||||||
target text NOT NULL,
|
target text NOT NULL,
|
||||||
regex jsonb,
|
regex jsonb,
|
||||||
seq integer NOT NULL
|
seq integer NOT NULL,
|
||||||
|
hist jsonb
|
||||||
);
|
);
|
||||||
COMMENT ON TABLE tps.map_rm IS 'regex map instructions';
|
COMMENT ON TABLE tps.map_rm IS 'regex map instructions';
|
||||||
|
|
||||||
|
@ -15,15 +15,36 @@ BEGIN
|
|||||||
INSERT INTO
|
INSERT INTO
|
||||||
tps.map_rm
|
tps.map_rm
|
||||||
SELECT
|
SELECT
|
||||||
|
--data source
|
||||||
_defn->>'srce'
|
_defn->>'srce'
|
||||||
|
--map name
|
||||||
,_defn->>'name'
|
,_defn->>'name'
|
||||||
|
--map definition
|
||||||
,_defn
|
,_defn
|
||||||
|
--map aggregation sequence
|
||||||
,_defn->>'sequence'
|
,_defn->>'sequence'
|
||||||
|
--history definition
|
||||||
|
,jsonb_build_object(
|
||||||
|
'hist_defn',_defn
|
||||||
|
,'effective',jsonb_build_array(CURRENT_TIMESTAMP,null::timestamptz)
|
||||||
|
) || '[]'::jsonb
|
||||||
ON CONFLICT ON CONSTRAINT map_rm_pk DO UPDATE SET
|
ON CONFLICT ON CONSTRAINT map_rm_pk DO UPDATE SET
|
||||||
srce = _defn->>'srce'
|
srce = _defn->>'srce'
|
||||||
,target = _defn->>'name'
|
,target = _defn->>'name'
|
||||||
,regex = _defn
|
,regex = _defn
|
||||||
,seq = _defn->>'sequence';
|
,seq = _defn->>'sequence'
|
||||||
|
,hist =
|
||||||
|
--the new definition going to position -0-
|
||||||
|
jsonb_build_object(
|
||||||
|
'hist_defn',_defn
|
||||||
|
,'effective',jsonb_build_array(CURRENT_TIMESTAMP,null::timestamptz)
|
||||||
|
)
|
||||||
|
--the previous definition, set upper bound of effective range which was previously null
|
||||||
|
|| jsonb_set(
|
||||||
|
map_rm.hist
|
||||||
|
,'{0,effective,1}'::text[]
|
||||||
|
,to_jsonb(CURRENT_TIMESTAMP)
|
||||||
|
);
|
||||||
|
|
||||||
EXCEPTION WHEN OTHERS THEN
|
EXCEPTION WHEN OTHERS THEN
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user