This repository was archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdb_schema_creation.sql
More file actions
842 lines (599 loc) · 21.1 KB
/
db_schema_creation.sql
File metadata and controls
842 lines (599 loc) · 21.1 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
--
-- PerfRepo postgresql database schema
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: metric; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE metric (
id bigint NOT NULL,
comparator character varying(255),
name character varying(2047) NOT NULL,
description character varying(10239)
);
ALTER TABLE public.metric OWNER TO perfrepo;
--
-- Name: metric_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE metric_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.metric_sequence OWNER TO perfrepo;
--
-- Name: tag; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE tag (
id bigint NOT NULL,
name character varying(255)
);
ALTER TABLE public.tag OWNER TO perfrepo;
--
-- Name: tag_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE tag_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.tag_sequence OWNER TO perfrepo;
--
-- Name: test; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE test (
id bigint NOT NULL,
groupid character varying(255) NOT NULL,
name character varying(2047) NOT NULL,
uid character varying(2047) NOT NULL,
description character varying(10239)
);
ALTER TABLE public.test OWNER TO perfrepo;
--
-- Name: test_execution; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE test_execution (
id bigint NOT NULL,
name character varying(255) NOT NULL,
test_id bigint NOT NULL,
started timestamp without time zone NOT NULL
);
ALTER TABLE public.test_execution OWNER TO perfrepo;
--
-- Name: test_execution_attachment; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE test_execution_attachment (
id bigint NOT NULL,
content oid NOT NULL,
filename character varying(2047) NOT NULL,
mimetype character varying(255) NOT NULL,
test_execution_id bigint NOT NULL
);
ALTER TABLE public.test_execution_attachment OWNER TO perfrepo;
--
-- Name: test_execution_attachment_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE test_execution_attachment_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.test_execution_attachment_sequence OWNER TO perfrepo;
--
-- Name: test_execution_parameter; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE test_execution_parameter (
id bigint NOT NULL,
name character varying(2047),
value character varying(2047),
test_execution_id bigint NOT NULL
);
ALTER TABLE public.test_execution_parameter OWNER TO perfrepo;
--
-- Name: test_execution_parameter_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE test_execution_parameter_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.test_execution_parameter_sequence OWNER TO perfrepo;
--
-- Name: test_execution_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE test_execution_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.test_execution_sequence OWNER TO perfrepo;
--
-- Name: test_execution_tag; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE test_execution_tag (
tag_id bigint NOT NULL,
test_execution_id bigint NOT NULL
);
ALTER TABLE public.test_execution_tag OWNER TO perfrepo;
--
-- Name: test_metric; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE test_metric (
metric_id bigint NOT NULL,
test_id bigint NOT NULL
);
ALTER TABLE public.test_metric OWNER TO perfrepo;
--
-- Name: test_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.test_sequence OWNER TO perfrepo;
--
-- Name: user; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE "user" (
id bigint NOT NULL,
username character varying(2047) NOT NULL,
password character varying(300) NOT NULL,
first_name character varying(2047) NOT NULL,
last_name character varying(2047) NOT NULL,
email character varying(2047) NOT NULL
);
ALTER TABLE public."user" OWNER TO perfrepo;
--
-- Name: user_property; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE user_property (
id bigint NOT NULL,
user_id bigint NOT NULL,
name character varying(2047) NOT NULL,
value character varying(2047) NOT NULL
);
ALTER TABLE public.user_property OWNER TO perfrepo;
--
-- Name: user_property_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE user_property_sequence
START WITH 100
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.user_property_sequence OWNER TO perfrepo;
--
-- Name: user_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE user_sequence
START WITH 100
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.user_sequence OWNER TO perfrepo;
--
-- Name: value; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE value (
id bigint NOT NULL,
result_value double precision,
metric_id bigint NOT NULL,
test_execution_id bigint NOT NULL
);
ALTER TABLE public.value OWNER TO perfrepo;
--
-- Name: value_parameter; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE value_parameter (
id bigint NOT NULL,
name character varying(255),
value character varying(255),
value_id bigint NOT NULL
);
ALTER TABLE public.value_parameter OWNER TO perfrepo;
--
-- Name: value_parameter_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE value_parameter_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.value_parameter_sequence OWNER TO perfrepo;
--
-- Name: value_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE value_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.value_sequence OWNER TO perfrepo;
--
-- Name: metric_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY metric
ADD CONSTRAINT metric_pkey PRIMARY KEY (id);
--
-- Name: tag_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY tag
ADD CONSTRAINT tag_pkey PRIMARY KEY (id);
--
-- Name: test_execution_attachment_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test_execution_attachment
ADD CONSTRAINT test_execution_attachment_pkey PRIMARY KEY (id);
--
-- Name: test_execution_parameter_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test_execution_parameter
ADD CONSTRAINT test_execution_parameter_pkey PRIMARY KEY (id);
--
-- Name: test_execution_parameter_unique_name; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test_execution_parameter
ADD CONSTRAINT test_execution_parameter_unique_name UNIQUE (name, test_execution_id);
--
-- Name: test_execution_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test_execution
ADD CONSTRAINT test_execution_pkey PRIMARY KEY (id);
--
-- Name: test_execution_tag_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test_execution_tag
ADD CONSTRAINT test_execution_tag_pkey PRIMARY KEY (tag_id);
--
-- Name: test_metric_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test_metric
ADD CONSTRAINT test_metric_pkey PRIMARY KEY (metric_id);
--
-- Name: test_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test
ADD CONSTRAINT test_pkey PRIMARY KEY (id);
--
-- Name: test_uid_key; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY test
ADD CONSTRAINT test_uid_key UNIQUE (uid);
--
-- Name: user_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY "user"
ADD CONSTRAINT user_pkey PRIMARY KEY (id);
--
-- Name: user_property_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY user_property
ADD CONSTRAINT user_property_pkey PRIMARY KEY (id);
--
-- Name: user_property_unique_name; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY user_property
ADD CONSTRAINT user_property_unique_name UNIQUE (name, user_id);
--
-- Name: user_unique_username; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY "user"
ADD CONSTRAINT user_unique_username UNIQUE (username);
--
-- Name: value_parameter_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY value_parameter
ADD CONSTRAINT value_parameter_pkey PRIMARY KEY (id);
--
-- Name: value_pkey; Type: CONSTRAINT; Schema: public; Owner: perfrepo; Tablespace:
--
ALTER TABLE ONLY value
ADD CONSTRAINT value_pkey PRIMARY KEY (id);
--
-- Name: fk6ac9171c4825995; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY value
ADD CONSTRAINT fk6ac9171c4825995 FOREIGN KEY (metric_id) REFERENCES metric(id);
--
-- Name: fk6ac9171fdfcba9a; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY value
ADD CONSTRAINT fk6ac9171fdfcba9a FOREIGN KEY (test_execution_id) REFERENCES test_execution(id);
--
-- Name: fk8f4e9015fdfcba9a; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_execution_parameter
ADD CONSTRAINT fk8f4e9015fdfcba9a FOREIGN KEY (test_execution_id) REFERENCES test_execution(id);
--
-- Name: fkc4d93bab3f0c1115; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_execution
ADD CONSTRAINT fkc4d93bab3f0c1115 FOREIGN KEY (test_id) REFERENCES test(id);
--
-- Name: fkca230a37fdfcba9a; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_execution_attachment
ADD CONSTRAINT fkca230a37fdfcba9a FOREIGN KEY (test_execution_id) REFERENCES test_execution(id);
--
-- Name: fke696c5fd3f0c1115; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_metric
ADD CONSTRAINT fke696c5fd3f0c1115 FOREIGN KEY (test_id) REFERENCES test(id) ON DELETE CASCADE;
--
-- Name: fke696c5fdc4825995; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_metric
ADD CONSTRAINT fke696c5fdc4825995 FOREIGN KEY (metric_id) REFERENCES metric(id) ON DELETE CASCADE;
--
-- Name: fkf95a5d06e904537f; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_execution_tag
ADD CONSTRAINT fkf95a5d06e904537f FOREIGN KEY (tag_id) REFERENCES tag(id) ON DELETE CASCADE;
--
-- Name: fkf95a5d06fdfcba9a; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY test_execution_tag
ADD CONSTRAINT fkf95a5d06fdfcba9a FOREIGN KEY (test_execution_id) REFERENCES test_execution(id) ON DELETE CASCADE;
--
-- Name: fkfd9de65b92d882df; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY value_parameter
ADD CONSTRAINT fkfd9de65b92d882df FOREIGN KEY (value_id) REFERENCES value(id) ON DELETE CASCADE;
--
-- Name: user_property_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: perfrepo
--
ALTER TABLE ONLY user_property
ADD CONSTRAINT user_property_user_fkey FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE CASCADE;
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
--REVOKE ALL ON SCHEMA public FROM postgres;
--GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
-----------------------------------------------------------------------------------------------
-- --
-- Upgrade of db schema from version 0.0.13 to 0.0.14 --
-- --
-----------------------------------------------------------------------------------------------
ALTER TABLE test_execution
ADD job_id bigint NULL,
ADD comment character varying(10239) NULL;
-----------------------------------------------------------------------------------------------
-- --
-- Upgrade of db schema from version 0.0.14 to 0.0.16 --
-- --
-----------------------------------------------------------------------------------------------
CREATE INDEX value_test_execution ON value(test_execution_id);
CREATE INDEX value_parameter_value ON value_parameter(value_id);
CREATE INDEX test_execution_test ON test_execution(test_id);
CREATE INDEX test_metric_test ON test_metric(test_id);
CREATE INDEX test_metric_metric ON test_metric(metric_id);
CREATE INDEX test_execution_tag_test_execution ON test_execution_tag(test_execution_id);
CREATE INDEX test_execution_parameter_test_execution ON test_execution_parameter(test_execution_id);
--
-- Name: report; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE report (
id bigint NOT NULL,
name character varying(255) NOT NULL,
type character varying(255) NOT NULL,
user_id bigint NOT NULL
);
ALTER TABLE public.report OWNER TO perfrepo;
ALTER TABLE ONLY public.report
ADD CONSTRAINT report_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.report
ADD CONSTRAINT report_user_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);
CREATE INDEX report_user_id ON report(user_id);
--
-- Name: report_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE report_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.report_sequence OWNER TO perfrepo;
--
-- Name: report_property; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE report_property (
id bigint NOT NULL,
report_id bigint NOT NULL,
name character varying(2047) NOT NULL,
value character varying(8192) NOT NULL
);
ALTER TABLE public.report_property OWNER TO perfrepo;
ALTER TABLE ONLY public.report_property
ADD CONSTRAINT report_property_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.report_property
ADD CONSTRAINT report_property_report_fkey FOREIGN KEY (report_id) REFERENCES "report"(id);
CREATE INDEX report_property_report_id ON report_property(report_id);
--
-- Name: report_property_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE report_property_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.report_property_sequence OWNER TO perfrepo;
--
-- Name: favorite_parameter; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE favorite_parameter (
id bigint NOT NULL,
user_id bigint NOT NULL,
test_id bigint NOT NULL,
label character varying(2047) NOT NULL,
parameter_name character varying(2047) NOT NULL
);
ALTER TABLE public.favorite_parameter OWNER TO perfrepo;
ALTER TABLE ONLY public.favorite_parameter
ADD CONSTRAINT favorite_parameter_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.favorite_parameter
ADD CONSTRAINT favorite_parameter_user_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);
ALTER TABLE ONLY public.favorite_parameter
ADD CONSTRAINT favorite_parameter_test_fkey FOREIGN KEY (test_id) REFERENCES "test"(id);
CREATE INDEX favorite_parameter_user_id ON favorite_parameter(user_id);
--
-- Name: favorite_parameter_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE favorite_parameter_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.favorite_parameter_sequence OWNER TO perfrepo;
--
-- Name: group; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE "group" (
id bigint NOT NULL,
name character varying(100) NOT NULL
);
ALTER TABLE public.group OWNER TO perfrepo;
ALTER TABLE ONLY public.group
ADD CONSTRAINT group_pkey PRIMARY KEY (id);
--
-- Name: group_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE group_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.group_sequence OWNER TO perfrepo;
--
-- Name: user_group; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE user_group (
user_id bigint NOT NULL,
group_id bigint NOT NULL
);
ALTER TABLE public.user_group OWNER TO perfrepo;
ALTER TABLE ONLY public.user_group
ADD CONSTRAINT user_group_pkey PRIMARY KEY (user_id, group_id);
ALTER TABLE ONLY public.user_group
ADD CONSTRAINT user_group_group_fkey FOREIGN KEY (group_id) REFERENCES "group"(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.user_group
ADD CONSTRAINT user_group_user_fkey FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE CASCADE;
--
-- Name: permission; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE permission (
id bigint NOT NULL,
report_id bigint,
access_type character varying(20) NOT NULL,
access_level character varying(20) NOT NULL,
group_id bigint,
user_id bigint
);
ALTER TABLE public.permission OWNER TO perfrepo;
ALTER TABLE ONLY public.permission
ADD CONSTRAINT permission_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.permission
ADD CONSTRAINT permission_report_fkey FOREIGN KEY(report_id) REFERENCES "report"(id);
ALTER TABLE ONLY public.permission
ADD CONSTRAINT permission_group_fkey FOREIGN KEY (group_id) REFERENCES "group"(id);
ALTER TABLE ONLY public.permission
ADD CONSTRAINT permission_user_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);
--
-- Name: permission_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE permission_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.permission_sequence OWNER TO perfrepo;
CREATE TABLE test_subscriber (
test_id bigint NOT NULL,
user_id bigint NOT NULL
);
ALTER TABLE public.test_subscriber OWNER TO perfrepo;
ALTER TABLE ONLY public.test_subscriber
ADD CONSTRAINT test_subscriber_pkey PRIMARY KEY (test_id, user_id);
ALTER TABLE ONLY public.test_subscriber
ADD CONSTRAINT test_subscriber_test_fkey FOREIGN KEY (test_id) REFERENCES test(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.test_subscriber
ADD CONSTRAINT test_subscriber_user_fkey FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE CASCADE;
CREATE INDEX test_subscriber_test ON test_subscriber(test_id);
CREATE INDEX test_subscriber_user ON test_subscriber(user_id);
--
-- Name: alert; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE alert (
id bigint NOT NULL,
name character varying(2097) NOT NULL,
links character varying(2097),
description character varying(2097),
condition character varying(2097) NOT NULL,
metric_id bigint NOT NULL,
test_id bigint NOT NULL
);
ALTER TABLE public.alert OWNER TO perfrepo;
ALTER TABLE ONLY public.alert
ADD CONSTRAINT alert_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.alert
ADD CONSTRAINT alert_metric_fkey FOREIGN KEY (metric_id) REFERENCES metric(id);
ALTER TABLE ONLY public.alert
ADD CONSTRAINT alert_test_fkey FOREIGN KEY (test_id) REFERENCES test(id);
CREATE INDEX alert_metric_id ON alert(metric_id);
CREATE INDEX alert_test_id ON alert(test_id);
--
-- Name: alert_sequence; Type: SEQUENCE; Schema: public; Owner: perfrepo
--
CREATE SEQUENCE alert_sequence
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: alert_tag; Type: TABLE; Schema: public; Owner: perfrepo; Tablespace:
--
CREATE TABLE alert_tag (
alert_id bigint NOT NULL,
tag_id bigint NOT NULL
);
ALTER TABLE public.alert_tag OWNER TO perfrepo;
ALTER TABLE ONLY public.alert_tag
ADD CONSTRAINT alert_tag_pkey PRIMARY KEY (alert_id, tag_id);
ALTER TABLE ONLY public.alert_tag
ADD CONSTRAINT alert_tag_alert_fkey FOREIGN KEY (alert_id) REFERENCES alert(id);
ALTER TABLE ONLY public.alert_tag
ADD CONSTRAINT alert_tag_tag_fkey FOREIGN KEY (tag_id) REFERENCES tag(id);
CREATE INDEX alert_tag_alert ON alert_tag(alert_id);
CREATE INDEX alert_tag_tag ON alert_tag(tag_id);
--
-- User/Group data
--
insert into public.user (id, username, first_name, last_name, email, password) values (nextVal('user_sequence'), 'perfrepouser', 'perfrepouser', 'perfrepouser', 'example@example.com', '/+aGXwHMbhcz5HDdSx9FRg==');
insert into public.group (id, name) values (nextVal('group_sequence'), 'perfrepouser');
insert into user_group (user_id, group_id) values ((select id from public.user where username='perfrepouser'), (select id from public.group where name='perfrepouser'));