1 -- ================================================================================
2 -- Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
3 -- ================================================================================
4 -- Licensed under the Apache License, Version 2.0 (the "License");
5 -- you may not use this file except in compliance with the License.
6 -- You may obtain a copy of the License at
8 -- http://www.apache.org/licenses/LICENSE-2.0
10 -- Unless required by applicable law or agreed to in writing, software
11 -- distributed under the License is distributed on an "AS IS" BASIS,
12 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 -- See the License for the specific language governing permissions and
14 -- limitations under the License.
15 -- ============LICENSE_END=========================================================
17 CREATE SCHEMA IF NOT EXISTS dti AUTHORIZATION dti_admin;
19 CREATE SEQUENCE IF NOT EXISTS dti.dtih_event_event_id_seq;
21 CREATE TABLE IF NOT EXISTS dti.dtih_event
23 dtih_event_id integer NOT NULL DEFAULT nextval('dti.dtih_event_event_id_seq'::regclass),
24 create_ts timestamp with time zone DEFAULT now(),
26 target_name character varying(80),
27 target_type character varying(50),
28 last_modified_ts timestamp with time zone,
29 location_clli character varying(50),
30 CONSTRAINT dtih_event_pkey PRIMARY KEY (dtih_event_id)
33 CREATE UNIQUE INDEX IF NOT EXISTS "dtih_event_UK"
34 ON dti.dtih_event USING btree
35 (target_name, target_type)
36 TABLESPACE pg_default;
38 CREATE SEQUENCE IF NOT EXISTS dti.dtih_event_ack_event_ack_id_seq;
40 CREATE TABLE IF NOT EXISTS dti.dtih_event_ack
42 dtih_event_ack_id integer NOT NULL DEFAULT nextval('dti.dtih_event_ack_event_ack_id_seq'::regclass),
43 last_modified_ts timestamp with time zone DEFAULT now(),
44 k8s_cluster_fqdn character varying(80),
45 k8s_proxy_fqdn character varying(80),
46 k8s_pod_id character varying(80),
47 dtih_event_id integer,
48 k8s_namespace character varying(100),
49 k8s_service_name character varying(120),
50 k8s_service_port character varying(6),
51 create_ts timestamp with time zone,
52 action character varying(10),
53 service_component character varying(120),
54 deployment_id character varying(120),
55 container_type character varying(10),
56 docker_host character varying(120),
57 container_id character varying(120),
58 reconfig_script character varying(100),
59 CONSTRAINT dtih_event_ack_pkey PRIMARY KEY (dtih_event_ack_id),
60 CONSTRAINT event_ack_fk FOREIGN KEY (dtih_event_id)
61 REFERENCES dti.dtih_event (dtih_event_id) MATCH SIMPLE
66 CREATE INDEX IF NOT EXISTS fki_dtih_event_ack_fk
67 ON dti.dtih_event_ack USING btree
69 TABLESPACE pg_default;
71 CREATE OR REPLACE FUNCTION dti.trigger_set_timestamp()
74 NEW.last_modified_ts = NOW();
79 CREATE TRIGGER set_timestamp
80 BEFORE UPDATE ON dti.dtih_event_ack
82 EXECUTE PROCEDURE dti.trigger_set_timestamp();
84 CREATE TRIGGER set_timestamp_evt
85 BEFORE UPDATE ON dti.dtih_event
87 EXECUTE PROCEDURE dti.trigger_set_timestamp();