This repository was archived by the owner on Nov 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 355
Expand file tree
/
Copy pathcreate_tables.sql
More file actions
4034 lines (3184 loc) · 131 KB
/
Copy pathcreate_tables.sql
File metadata and controls
4034 lines (3184 loc) · 131 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
--
-- PostgreSQL database dump
--
-- Dumped from database version 13.12
-- Dumped by pg_dump version 13.12
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
SET search_path = public, pg_catalog;
--
-- Name: on_update_current_timestamp_last_updated(); Type: FUNCTION; Schema: public; Owner: traffic_ops
--
CREATE OR REPLACE FUNCTION on_update_current_timestamp_last_updated() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.last_updated = now();
RETURN NEW;
END;
$$;
ALTER FUNCTION public.on_update_current_timestamp_last_updated() OWNER TO traffic_ops;
--
-- Name: before_server_table(); Type: FUNCTION; Schema: public; Owner: traffic_ops
--
CREATE OR REPLACE FUNCTION before_server_table()
RETURNS TRIGGER AS
$$
DECLARE
server_count BIGINT;
BEGIN
WITH server_ips AS (
SELECT s.id, i.name, ip.address, s.profile
FROM server s
JOIN interface i on i.server = s.ID
JOIN ip_address ip on ip.Server = s.ID and ip.interface = i.name
WHERE i.monitor = true
)
SELECT count(*)
INTO server_count
FROM server_ips sip
JOIN server_ips sip2 on sip.id <> sip2.id
WHERE sip.id = NEW.id
AND sip2.address = sip.address
AND sip2.profile = sip.profile;
IF server_count > 0 THEN
RAISE EXCEPTION 'Server [id:%] does not have a unique ip_address over the profile [id:%], [%] conflicts',
NEW.id,
NEW.profile,
server_count;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
ALTER FUNCTION public.before_server_table() OWNER TO traffic_ops;
--
-- Name: before_ip_address_table(); Type: FUNCTION; Schema: public; Owner: traffic_ops
--
CREATE OR REPLACE FUNCTION before_ip_address_table()
RETURNS TRIGGER
AS
$$
DECLARE
server_count BIGINT;
server_id BIGINT;
server_profile BIGINT;
BEGIN
WITH server_ips AS (
SELECT s.id as sid, ip.interface, i.name, ip.address, s.profile, ip.server
FROM server s
JOIN interface i
on i.server = s.ID
JOIN ip_address ip
on ip.Server = s.ID and ip.interface = i.name
WHERE ip.service_address = true
)
SELECT count(distinct(sip.sid)), sip.sid, sip.profile
INTO server_count, server_id, server_profile
FROM server_ips sip
WHERE (sip.server <> NEW.server AND (SELECT host(sip.address)) = (SELECT host(NEW.address)) AND sip.profile = (SELECT profile from server s WHERE s.id = NEW.server))
GROUP BY sip.sid, sip.profile;
IF server_count > 0 THEN
RAISE EXCEPTION 'ip_address is not unique across the server [id:%] profile [id:%], [%] conflicts',
server_id,
server_profile,
server_count;
END IF;
RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;
ALTER FUNCTION public.before_ip_address_table() OWNER TO traffic_ops;
--
-- Name: on_delete_current_timestamp_last_updated(); Type: FUNCTION; Schema: public; Owner: traffic_ops
--
CREATE OR REPLACE FUNCTION on_delete_current_timestamp_last_updated()
RETURNS trigger
AS $$
BEGIN
update last_deleted set last_updated = now() where table_name = TG_ARGV[0];
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION on_delete_current_timestamp_last_updated() OWNER TO traffic_ops;
--
-- Name: update_ds_timestamp_on_insert(); Type: FUNCTION; Schema: public; Owner: traffic_ops
--
CREATE OR REPLACE FUNCTION update_ds_timestamp_on_insert()
RETURNS trigger
AS $$
BEGIN
UPDATE deliveryservice
SET last_updated=now()
WHERE id IN (
SELECT deliveryservice
FROM CAST(NEW AS deliveryservice_tls_version)
);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
--
-- Name: update_ds_timestamp_on_delete(); Type: FUNCTION; Schema: public; Owner: traffic_ops
--
CREATE OR REPLACE FUNCTION update_ds_timestamp_on_delete()
RETURNS trigger
AS $$
BEGIN
UPDATE deliveryservice
SET last_updated=now()
WHERE id IN (
SELECT deliveryservice
FROM CAST(OLD AS deliveryservice_tls_version)
);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
SET default_tablespace = '';
SET default_with_oids = false;
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'change_types') THEN
--
-- Name: change_types; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE change_types AS ENUM (
'create',
'update',
'delete'
);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'deep_caching_type') THEN
--
-- Name: deep_caching_type; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE deep_caching_type AS ENUM (
'NEVER',
'ALWAYS'
);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'http_method_t') THEN
--
-- Name: http_method_t; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE http_method_t AS ENUM (
'GET',
'POST',
'PUT',
'PATCH',
'DELETE'
);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'origin_protocol') THEN
--
-- Name: localization_method; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE localization_method AS ENUM (
'CZ',
'DEEP_CZ',
'GEO'
);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'origin_protocol') THEN
--
-- Name: origin_protocol; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE origin_protocol AS ENUM (
'http',
'https'
);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'profile_type') THEN
--
-- Name: profile_type; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE profile_type AS ENUM (
'ATS_PROFILE',
'TR_PROFILE',
'TM_PROFILE',
'TS_PROFILE',
'TP_PROFILE',
'INFLUXDB_PROFILE',
'RIAK_PROFILE',
'SPLUNK_PROFILE',
'DS_PROFILE',
'ORG_PROFILE',
'KAFKA_PROFILE',
'LOGSTASH_PROFILE',
'ES_PROFILE',
'UNK_PROFILE',
'GROVE_PROFILE'
);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'workflow_states') THEN
--
-- Name: workflow_states; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE workflow_states AS ENUM (
'draft',
'submitted',
'rejected',
'pending',
'complete'
);
END IF;
IF NOT EXISTS(SELECT FROM pg_type WHERE typname = 'server_ip_address') THEN
--
-- Name: server_ip_address; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE server_ip_address AS (address inet, gateway inet, service_address boolean);
END IF;
IF NOT EXISTS(SELECT FROM pg_type WHERE typname = 'server_interface') THEN
--
-- Name: server_interface; Type: TYPE; Schema: public; Owner: traffic_ops
--
CREATE TYPE server_interface AS (ip_addresses server_ip_address ARRAY, max_bandwidth bigint, monitor boolean, mtu bigint, name text);
END IF;
IF NOT EXISTS (SELECT FROM pg_type WHERE typname = 'deliveryservice_signature_type') THEN
--
-- Name: deliveryservice_signature_type; Type: DOMAIN; Schema: public; Owner: traffic_ops
--
CREATE DOMAIN deliveryservice_signature_type AS text CHECK (VALUE IN ('url_sig', 'uri_signing'));
END IF;
END$$;
--
-- Name: acme_account; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS acme_account (
email text NOT NULL,
private_key text NOT NULL,
provider text NOT NULL,
uri text NOT NULL,
PRIMARY KEY (email, provider)
);
--
-- Name: api_capability; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS api_capability (
id bigserial PRIMARY KEY,
http_method http_method_t NOT NULL,
route text NOT NULL,
capability text NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
UNIQUE (http_method, route, capability)
);
ALTER TABLE api_capability OWNER TO traffic_ops;
--
-- Name: asn; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS asn (
id bigint NOT NULL,
asn bigint NOT NULL,
cachegroup bigint DEFAULT '0'::bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89468_primary PRIMARY KEY (id, cachegroup)
);
ALTER TABLE asn OWNER TO traffic_ops;
--
-- Name: asn_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS asn_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE asn_id_seq OWNER TO traffic_ops;
--
-- Name: asn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE asn_id_seq OWNED BY asn.id;
--
-- Name: async_status; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS async_status (
id bigint NOT NULL,
status TEXT NOT NULL,
message TEXT,
start_time timestamp with time zone DEFAULT now() NOT NULL,
end_time timestamp with time zone,
CONSTRAINT async_status_pkey PRIMARY KEY (id)
);
ALTER TABLE async_status OWNER TO traffic_ops;
--
-- Name: async_status_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS async_status_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE async_status_id_seq OWNER TO traffic_ops;
--
-- Name: async_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE async_status_id_seq OWNED BY async_status.id;
--
-- Name: cachegroup; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS cachegroup (
id bigint,
name text NOT NULL,
short_name text NOT NULL,
parent_cachegroup_id bigint,
secondary_parent_cachegroup_id bigint,
type bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
fallback_to_closest boolean DEFAULT TRUE,
coordinate bigint,
CONSTRAINT idx_89476_primary PRIMARY KEY (id, type)
);
ALTER TABLE cachegroup OWNER TO traffic_ops;
--
-- Name: cachegroup_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS cachegroup_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE cachegroup_id_seq OWNER TO traffic_ops;
--
-- Name: cachegroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE cachegroup_id_seq OWNED BY cachegroup.id;
--
-- Name: cachegroup_fallbacks; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS cachegroup_fallbacks (
primary_cg bigint NOT NULL,
backup_cg bigint NOT NULL CHECK (primary_cg != backup_cg),
set_order bigint NOT NULL,
UNIQUE (primary_cg, backup_cg),
UNIQUE (primary_cg, set_order)
);
ALTER TABLE cachegroup_fallbacks OWNER TO traffic_ops;
--
-- Name: cachegroup_localization_method; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS cachegroup_localization_method (
cachegroup bigint NOT NULL,
method localization_method NOT NULL,
UNIQUE (cachegroup, method)
);
--
-- Name: cachegroup_parameter; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS cachegroup_parameter (
cachegroup bigint DEFAULT '0'::bigint NOT NULL,
parameter bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89484_primary PRIMARY KEY (cachegroup, parameter)
);
ALTER TABLE cachegroup_parameter OWNER TO traffic_ops;
--
-- Name: capability; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS capability (
name text NOT NULL,
description text,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT capability_pkey PRIMARY KEY (name)
);
ALTER TABLE capability OWNER TO traffic_ops;
--
-- Name: cdn; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS cdn (
id bigint,
name text NOT NULL,
last_updated timestamp with time zone DEFAULT now() NOT NULL,
dnssec_enabled boolean DEFAULT false NOT NULL,
domain_name text NOT NULL,
CONSTRAINT cdn_domain_name_unique UNIQUE (domain_name),
CONSTRAINT idx_89491_primary PRIMARY KEY (id)
);
ALTER TABLE cdn OWNER TO traffic_ops;
--
-- Name: cdn_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS cdn_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE cdn_id_seq OWNER TO traffic_ops;
--
-- Name: cdn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE cdn_id_seq OWNED BY cdn.id;
--
-- Name: cdn_lock; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS cdn_lock (
username text NOT NULL,
cdn text NOT NULL,
message text,
soft boolean NOT NULL DEFAULT TRUE,
last_updated timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT pk_cdn_lock PRIMARY KEY ("cdn")
);
ALTER TABLE cdn_lock OWNER TO traffic_ops;
--
-- Name: cdn_notification; Type: TABLE; Schema: public; Owner: traffic_ops
CREATE TABLE cdn_notification (
id bigint NOT NULL,
cdn text NOT NULL,
"user" text NOT NULL,
notification text NOT NULL,
last_updated timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT cdn_notification_pkey PRIMARY KEY (id)
);
ALTER TABLE cdn_notification OWNER TO traffic_ops;
--
-- Name: cdn_notification_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS cdn_notification_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE cdn_notification_id_seq OWNER TO traffic_ops;
--
-- Name: cdn_notification_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE cdn_notification_id_seq OWNED BY cdn_notification.id;
--
-- Name: coordinate; Type: TABLE; Schema: public: Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS coordinate (
id bigserial,
name text UNIQUE NOT NULL,
latitude numeric NOT NULL DEFAULT 0.0,
longitude numeric NOT NULL DEFAULT 0.0,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT coordinate_pkey PRIMARY KEY (id)
);
--
-- Name: deliveryservice; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice (
id bigint,
xml_id text NOT NULL,
active boolean DEFAULT false NOT NULL,
dscp bigint NOT NULL,
signing_algorithm deliveryservice_signature_type,
qstring_ignore smallint,
geo_limit smallint DEFAULT '0'::smallint,
http_bypass_fqdn text,
dns_bypass_ip text,
dns_bypass_ip6 text,
dns_bypass_ttl bigint,
type bigint NOT NULL,
profile bigint,
cdn_id bigint NOT NULL,
ccr_dns_ttl bigint,
global_max_mbps bigint,
global_max_tps bigint,
long_desc text,
long_desc_1 text,
long_desc_2 text,
max_dns_answers bigint DEFAULT '5'::bigint,
info_url text,
miss_lat numeric,
miss_long numeric,
check_path text,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
protocol smallint DEFAULT '0'::smallint,
ssl_key_version bigint DEFAULT '0'::bigint,
ipv6_routing_enabled boolean DEFAULT false,
range_request_handling smallint DEFAULT '0'::smallint,
edge_header_rewrite text,
origin_shield text,
mid_header_rewrite text,
regex_remap text,
cacheurl text,
remap_text text,
multi_site_origin boolean DEFAULT false,
display_name text NOT NULL,
tr_response_headers text,
initial_dispersion bigint DEFAULT '1'::bigint,
dns_bypass_cname text,
tr_request_headers text,
regional_geo_blocking boolean DEFAULT false NOT NULL,
geo_provider smallint DEFAULT '0'::smallint,
geo_limit_countries text,
logs_enabled boolean DEFAULT false,
geolimit_redirect_url text,
tenant_id bigint NOT NULL,
routing_name text NOT NULL DEFAULT 'cdn',
deep_caching_type deep_caching_type NOT NULL DEFAULT 'NEVER',
fq_pacing_rate bigint DEFAULT 0,
anonymous_blocking_enabled boolean NOT NULL DEFAULT FALSE,
consistent_hash_regex text,
max_origin_connections bigint NOT NULL DEFAULT 0 CHECK (max_origin_connections >= 0),
ecs_enabled boolean NOT NULL DEFAULT false,
range_slice_block_size integer CHECK (range_slice_block_size >= 262144 AND range_slice_block_size <= 33554432) DEFAULT NULL,
topology text,
first_header_rewrite text,
inner_header_rewrite text,
last_header_rewrite text,
service_category text,
max_request_header_bytes int NOT NULL DEFAULT 0,
CONSTRAINT routing_name_not_empty CHECK ((length(routing_name) > 0)),
CONSTRAINT idx_89502_primary PRIMARY KEY (id, type)
);
ALTER TABLE deliveryservice OWNER TO traffic_ops;
--
-- Name: deliveryservices_required_capability; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservices_required_capability (
required_capability TEXT NOT NULL,
deliveryservice_id bigint NOT NULL,
last_updated timestamp with time zone DEFAULT now() NOT NULL,
PRIMARY KEY (deliveryservice_id, required_capability)
);
--
-- Name: deliveryservice_consistent_hash_query_param; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice_consistent_hash_query_param (
name TEXT NOT NULL,
deliveryservice_id bigint NOT NULL,
CONSTRAINT name_empty CHECK (length(name) > 0),
CONSTRAINT name_reserved CHECK (name NOT IN ('format','trred')),
PRIMARY KEY (name, deliveryservice_id)
);
--
-- Name: deliveryservice_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS deliveryservice_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE deliveryservice_id_seq OWNER TO traffic_ops;
--
-- Name: deliveryservice_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE deliveryservice_id_seq OWNED BY deliveryservice.id;
--
-- Name: deliveryservice_regex; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice_regex (
deliveryservice bigint NOT NULL,
regex bigint NOT NULL,
set_number bigint DEFAULT '0'::bigint,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89517_primary PRIMARY KEY (deliveryservice, regex)
);
ALTER TABLE deliveryservice_regex OWNER TO traffic_ops;
--
-- Name: deliveryservice_request; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice_request (
assignee_id bigint,
author_id bigint NOT NULL,
change_type change_types NOT NULL,
created_at timestamp with time zone NOT NULL DEFAULT now(),
id bigserial,
last_edited_by_id bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
deliveryservice jsonb DEFAULT NULL,
status workflow_states NOT NULL,
original jsonb DEFAULT NULL,
CONSTRAINT deliveryservice_request_pkey PRIMARY KEY (id),
CONSTRAINT appropriate_requested_and_original_for_change_type CHECK (
(change_type = 'delete' AND original IS NOT NULL AND deliveryservice IS NULL)
OR
(change_type = 'create' AND original IS NULL AND deliveryservice IS NOT NULL)
OR (
change_type = 'update' AND
deliveryservice IS NOT NULL AND
(
(
(status = 'complete' OR status = 'rejected' OR status = 'pending')
AND
original IS NOT NULL
)
OR
(
(status = 'draft' OR status = 'submitted')
AND
original IS NULL
)
)
)
)
);
ALTER TABLE deliveryservice_request OWNER TO traffic_ops;
--
-- Name: deliveryservice_request_comment; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice_request_comment (
author_id bigint NOT NULL,
deliveryservice_request_id bigint NOT NULL,
id bigserial,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
value text NOT NULL,
CONSTRAINT deliveryservice_request_comment_pkey PRIMARY KEY (id)
);
--
-- Name: deliveryservice_server; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice_server (
deliveryservice bigint NOT NULL,
server bigint NOT NULL,
last_updated timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT idx_89521_primary PRIMARY KEY (deliveryservice, server)
);
ALTER TABLE deliveryservice_server OWNER TO traffic_ops;
--
-- Name: deliveryservice_tls_version; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS deliveryservice_tls_version (
deliveryservice bigint NOT NULL,
tls_version text NOT NULL,
CONSTRAINT deliveryservice_tls_version_pkey PRIMARY KEY (deliveryservice, tls_version),
CONSTRAINT deliveryservice_tls_version_tls_version_check CHECK (tls_version <> '')
);
ALTER TABLE deliveryservice_tls_version OWNER TO traffic_ops;
--
-- Name: update_ds_timestamp_on_tls_version_insertion; Type: TRIGGER; Schema: public; Owner: traffic_ops
--
DROP TRIGGER IF EXISTS update_ds_timestamp_on_tls_version_insertion on deliveryservice_tls_version;
CREATE TRIGGER update_ds_timestamp_on_tls_version_insertion
AFTER INSERT ON deliveryservice_tls_version
FOR EACH ROW EXECUTE PROCEDURE update_ds_timestamp_on_insert();
--
-- Name: update_ds_timestamp_on_tls_version_delete; Type: TRIGGER; Schema: public; Owner: traffic_ops
--
DROP TRIGGER IF EXISTS update_ds_timestamp_on_tls_version_delete on deliveryservice_tls_version;
CREATE TRIGGER update_ds_timestamp_on_tls_version_delete
AFTER DELETE ON deliveryservice_tls_version
FOR EACH ROW EXECUTE PROCEDURE update_ds_timestamp_on_delete();
--
-- Name: division; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS division (
id bigint NOT NULL,
name text NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89531_primary PRIMARY KEY (id)
);
ALTER TABLE division OWNER TO traffic_ops;
--
-- Name: division_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS division_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE division_id_seq OWNER TO traffic_ops;
--
-- Name: division_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE division_id_seq OWNED BY division.id;
--
-- Name: dnschallenges; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS dnschallenges (
fqdn text NOT NULL,
record text NOT NULL,
xml_id text NOT NULL
);
--
-- Name: federation; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS federation (
id bigint NOT NULL,
cname text NOT NULL,
description text,
ttl integer NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89541_primary PRIMARY KEY (id)
);
ALTER TABLE federation OWNER TO traffic_ops;
--
-- Name: federation_deliveryservice; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS federation_deliveryservice (
federation bigint NOT NULL,
deliveryservice bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89549_primary PRIMARY KEY (federation, deliveryservice)
);
ALTER TABLE federation_deliveryservice OWNER TO traffic_ops;
--
-- Name: federation_federation_resolver; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS federation_federation_resolver (
federation bigint NOT NULL,
federation_resolver bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89553_primary PRIMARY KEY (federation, federation_resolver)
);
ALTER TABLE federation_federation_resolver OWNER TO traffic_ops;
--
-- Name: federation_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS federation_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE federation_id_seq OWNER TO traffic_ops;
--
-- Name: federation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE federation_id_seq OWNED BY federation.id;
--
-- Name: federation_resolver; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS federation_resolver (
id bigint NOT NULL,
ip_address text NOT NULL,
type bigint NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89559_primary PRIMARY KEY (id)
);
ALTER TABLE federation_resolver OWNER TO traffic_ops;
--
-- Name: federation_resolver_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS federation_resolver_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE federation_resolver_id_seq OWNER TO traffic_ops;
--
-- Name: federation_resolver_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
--
ALTER SEQUENCE federation_resolver_id_seq OWNED BY federation_resolver.id;
--
-- Name: federation_tmuser; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS federation_tmuser (
federation bigint NOT NULL,
tm_user bigint NOT NULL,
role bigint,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89567_primary PRIMARY KEY (federation, tm_user)
);
ALTER TABLE federation_tmuser OWNER TO traffic_ops;
--
-- Name: hwinfo; Type: TABLE; Schema: public; Owner: traffic_ops
--
CREATE TABLE IF NOT EXISTS hwinfo (
id bigint NOT NULL,
serverid bigint NOT NULL,
description text NOT NULL,
val text NOT NULL,
last_updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT idx_89583_primary PRIMARY KEY (id)
);
ALTER TABLE hwinfo OWNER TO traffic_ops;
--
-- Name: hwinfo_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
--
CREATE SEQUENCE IF NOT EXISTS hwinfo_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE hwinfo_id_seq OWNER TO traffic_ops;
--