-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_clean.sql
More file actions
10536 lines (10201 loc) · 952 KB
/
db_clean.sql
File metadata and controls
10536 lines (10201 loc) · 952 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
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.0
-- Dumped by pg_dump version 9.6.0
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_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: promasy; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA IF NOT EXISTS promasy;
ALTER SCHEMA promasy OWNER TO postgres;
SET search_path = promasy, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: addresses; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE addresses (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
building_number character varying(255),
city character varying(255),
citytype character varying(255),
corpus_number character varying(255),
country character varying(255),
postal_code character varying(255),
region character varying(255),
street character varying(255),
streettype character varying(255)
);
ALTER TABLE addresses OWNER TO postgres;
--
-- Name: amount_units; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE amount_units (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
amount_unit_desc character varying(255)
);
ALTER TABLE amount_units OWNER TO postgres;
--
-- Name: bid_statuses; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE bid_statuses (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
status character varying(255),
bid_id bigint
);
ALTER TABLE bid_statuses OWNER TO postgres;
--
-- Name: bids; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE bids (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
amount integer,
bid_desc character varying(255),
cat_num character varying(255),
kekv integer,
one_price numeric(19,2),
proc_start_date date,
type character varying(255),
am_unit_id bigint,
cpv_code character varying(255),
finance_dep_id bigint,
producer_id bigint,
reason_id bigint,
supplier_id bigint
);
ALTER TABLE bids OWNER TO postgres;
--
-- Name: cpv; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE cpv (
cpv_code character varying(255) NOT NULL,
cpv_eng character varying(255),
cpv_level integer,
terminal boolean,
cpv_ukr character varying(255)
);
ALTER TABLE cpv OWNER TO postgres;
--
-- Name: departments; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE departments (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
dep_name character varying(255),
inst_id bigint
);
ALTER TABLE departments OWNER TO postgres;
--
-- Name: employees; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE employees (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
email character varying(255),
emp_fname character varying(255),
emp_lname character varying(255),
emp_mname character varying(255),
login character varying(255),
password character varying(255),
phone_main character varying(255),
phone_reserve character varying(255),
role character varying(255),
salt bigint,
subdep_id bigint
);
ALTER TABLE employees OWNER TO postgres;
--
-- Name: finance_dep; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE finance_dep (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
total_eqipment numeric(19,2),
total_materials numeric(19,2),
total_services numeric(19,2),
finance_id bigint,
subdep_id bigint
);
ALTER TABLE finance_dep OWNER TO postgres;
--
-- Name: finances; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE finances (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
due_to date,
name character varying(255),
number CHARACTER VARYING(255),
fundtype character varying(255),
kpkvk integer,
starts_on date,
total_equpment numeric(19,2),
total_materials numeric(19,2),
total_services numeric(19,2)
);
ALTER TABLE finances OWNER TO postgres;
--
-- Name: hilo_seqeunce; Type: SEQUENCE; Schema: promasy; Owner: postgres
--
CREATE SEQUENCE hilo_seqeunce
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE hilo_seqeunce OWNER TO postgres;
--
-- Name: institutes; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE institutes (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
email character varying(255),
edrpou integer,
fax_number character varying(255),
inst_name character varying(255),
phone_number character varying(255),
address_id bigint
);
ALTER TABLE institutes OWNER TO postgres;
--
-- Name: producers; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE producers (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
brand_name character varying(255)
);
ALTER TABLE producers OWNER TO postgres;
--
-- Name: reasons_for_suppl; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE reasons_for_suppl (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
reason_name character varying(255)
);
ALTER TABLE reasons_for_suppl OWNER TO postgres;
--
-- Name: registrations; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE registrations (
id integer NOT NULL,
registrations_left integer
);
ALTER TABLE registrations OWNER TO postgres;
--
-- Name: subdepartments; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE subdepartments (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
subdep_name character varying(255),
dep_id bigint
);
ALTER TABLE subdepartments OWNER TO postgres;
--
-- Name: suppliers; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE suppliers (
id bigint NOT NULL,
active boolean,
created_date timestamp without time zone,
modified_date timestamp without time zone,
version bigint NOT NULL,
created_by bigint,
modified_by bigint,
supplier_comments character varying(255),
supplier_name character varying(255),
supplier_tel character varying(255)
);
ALTER TABLE suppliers OWNER TO postgres;
--
-- Name: version; Type: TABLE; Schema: promasy; Owner: postgres
--
CREATE TABLE version (
id integer NOT NULL,
version_allowed character varying(255)
);
ALTER TABLE version OWNER TO postgres;
--
-- Data for Name: addresses; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY addresses (id, active, created_date, modified_date, version, created_by, modified_by, building_number, city, citytype, corpus_number, country, postal_code, region, street, streettype) FROM stdin;
\.
--
-- Data for Name: amount_units; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY amount_units (id, active, created_date, modified_date, version, created_by, modified_by, amount_unit_desc) FROM stdin;
\.
--
-- Data for Name: bid_statuses; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY bid_statuses (id, active, created_date, modified_date, version, created_by, modified_by, status, bid_id) FROM stdin;
\.
--
-- Data for Name: bids; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY bids (id, active, created_date, modified_date, version, created_by, modified_by, amount, bid_desc, cat_num, kekv, one_price, proc_start_date, type, am_unit_id, cpv_code, finance_dep_id, producer_id, reason_id, supplier_id) FROM stdin;
\.
--
-- Data for Name: cpv; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY cpv (cpv_code, cpv_eng, cpv_level, terminal, cpv_ukr) FROM stdin;
\.
--
-- Data for Name: departments; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY departments (id, active, created_date, modified_date, version, created_by, modified_by, dep_name, inst_id) FROM stdin;
\.
--
-- Data for Name: employees; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY employees (id, active, created_date, modified_date, version, created_by, modified_by, email, emp_fname, emp_lname, emp_mname, login, password, phone_main, phone_reserve, role, salt, subdep_id) FROM stdin;
\.
--
-- Data for Name: finance_dep; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY finance_dep (id, active, created_date, modified_date, version, created_by, modified_by, total_eqipment, total_materials, total_services, finance_id, subdep_id) FROM stdin;
\.
--
-- Data for Name: finances; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY finances (id, active, created_date, modified_date, version, created_by, modified_by, due_to, name, number, fundtype, kpkvk, starts_on, total_equpment, total_materials, total_services) FROM stdin;
\.
--
-- Name: hilo_seqeunce; Type: SEQUENCE SET; Schema: promasy; Owner: postgres
--
SELECT pg_catalog.setval('hilo_seqeunce', 1, false);
--
-- Data for Name: institutes; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY institutes (id, active, created_date, modified_date, version, created_by, modified_by, email, edrpou, fax_number, inst_name, phone_number, address_id) FROM stdin;
\.
--
-- Data for Name: producers; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY producers (id, active, created_date, modified_date, version, created_by, modified_by, brand_name) FROM stdin;
\.
--
-- Data for Name: reasons_for_suppl; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY reasons_for_suppl (id, active, created_date, modified_date, version, created_by, modified_by, reason_name) FROM stdin;
\.
--
-- Data for Name: registrations; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY registrations (id, registrations_left) FROM stdin;
\.
--
-- Data for Name: subdepartments; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY subdepartments (id, active, created_date, modified_date, version, created_by, modified_by, subdep_name, dep_id) FROM stdin;
\.
--
-- Data for Name: suppliers; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY suppliers (id, active, created_date, modified_date, version, created_by, modified_by, supplier_comments, supplier_name, supplier_tel) FROM stdin;
\.
--
-- Data for Name: version; Type: TABLE DATA; Schema: promasy; Owner: postgres
--
COPY version (id, version_allowed) FROM stdin;
1 0.8.0
\.
--
-- Name: addresses addresses_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY addresses
ADD CONSTRAINT addresses_pkey PRIMARY KEY (id);
--
-- Name: amount_units amount_units_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY amount_units
ADD CONSTRAINT amount_units_pkey PRIMARY KEY (id);
--
-- Name: bid_statuses bid_statuses_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bid_statuses
ADD CONSTRAINT bid_statuses_pkey PRIMARY KEY (id);
--
-- Name: bids bids_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT bids_pkey PRIMARY KEY (id);
--
-- Name: cpv cpv_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY cpv
ADD CONSTRAINT cpv_pkey PRIMARY KEY (cpv_code);
--
-- Name: departments departments_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY departments
ADD CONSTRAINT departments_pkey PRIMARY KEY (id);
--
-- Name: employees employees_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY employees
ADD CONSTRAINT employees_pkey PRIMARY KEY (id);
--
-- Name: finance_dep finance_dep_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finance_dep
ADD CONSTRAINT finance_dep_pkey PRIMARY KEY (id);
--
-- Name: finances finances_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finances
ADD CONSTRAINT finances_pkey PRIMARY KEY (id);
--
-- Name: institutes institutes_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY institutes
ADD CONSTRAINT institutes_pkey PRIMARY KEY (id);
--
-- Name: producers producers_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY producers
ADD CONSTRAINT producers_pkey PRIMARY KEY (id);
--
-- Name: reasons_for_suppl reasons_for_suppl_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY reasons_for_suppl
ADD CONSTRAINT reasons_for_suppl_pkey PRIMARY KEY (id);
--
-- Name: registrations registrations_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY registrations
ADD CONSTRAINT registrations_pkey PRIMARY KEY (id);
--
-- Name: subdepartments subdepartments_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY subdepartments
ADD CONSTRAINT subdepartments_pkey PRIMARY KEY (id);
--
-- Name: suppliers suppliers_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY suppliers
ADD CONSTRAINT suppliers_pkey PRIMARY KEY (id);
--
-- Name: version version_pkey; Type: CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY version
ADD CONSTRAINT version_pkey PRIMARY KEY (id);
--
-- Name: bids fk3vwxs2blly2fmoapleqlajw81; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fk3vwxs2blly2fmoapleqlajw81 FOREIGN KEY (reason_id) REFERENCES reasons_for_suppl(id);
--
-- Name: employees fk57hc214n1yj124owgi2r897ld; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY employees
ADD CONSTRAINT fk57hc214n1yj124owgi2r897ld FOREIGN KEY (subdep_id) REFERENCES subdepartments(id);
--
-- Name: institutes fk80nh0w61wfukjr3qxhqikot9q; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY institutes
ADD CONSTRAINT fk80nh0w61wfukjr3qxhqikot9q FOREIGN KEY (address_id) REFERENCES addresses(id);
--
-- Name: bids fk84ecql7gud3ljmru094ousih7; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fk84ecql7gud3ljmru094ousih7 FOREIGN KEY (supplier_id) REFERENCES suppliers(id);
--
-- Name: finance_dep fk9rtcqbbw7610hlr4f139fac70; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finance_dep
ADD CONSTRAINT fk9rtcqbbw7610hlr4f139fac70 FOREIGN KEY (subdep_id) REFERENCES subdepartments(id);
--
-- Name: addresses fk_344u93h6cd8jq5x5ckk4hu9f0; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY addresses
ADD CONSTRAINT fk_344u93h6cd8jq5x5ckk4hu9f0 FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: addresses fk_405w0w2rck8317hsoyg3w0flm; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY addresses
ADD CONSTRAINT fk_405w0w2rck8317hsoyg3w0flm FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: finance_dep fk_5u2k74wihjg53vssj5j6a31jo; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finance_dep
ADD CONSTRAINT fk_5u2k74wihjg53vssj5j6a31jo FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: bids fk_5wt5tqrim7hrkjlfpnoaa4kwt; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fk_5wt5tqrim7hrkjlfpnoaa4kwt FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: suppliers fk_8c6wn7rus6efwx1i1iv6fh2vo; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY suppliers
ADD CONSTRAINT fk_8c6wn7rus6efwx1i1iv6fh2vo FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: subdepartments fk_8uvr7ivg6inlao9bxte7uj3sm; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY subdepartments
ADD CONSTRAINT fk_8uvr7ivg6inlao9bxte7uj3sm FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: finances fk_9dq3rpet3cb8ltnarktkxik04; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finances
ADD CONSTRAINT fk_9dq3rpet3cb8ltnarktkxik04 FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: employees fk_9m5i22mnb9g9twtgw7c7b69pl; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY employees
ADD CONSTRAINT fk_9m5i22mnb9g9twtgw7c7b69pl FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: reasons_for_suppl fk_bj9ff672tjt7de6xklmuqdogd; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY reasons_for_suppl
ADD CONSTRAINT fk_bj9ff672tjt7de6xklmuqdogd FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: institutes fk_crs5g4jqdxfajyqtqn6ip5ll8; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY institutes
ADD CONSTRAINT fk_crs5g4jqdxfajyqtqn6ip5ll8 FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: reasons_for_suppl fk_e4eplnsbbs7nkirc239g9ortu; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY reasons_for_suppl
ADD CONSTRAINT fk_e4eplnsbbs7nkirc239g9ortu FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: subdepartments fk_er03pwih7shyvcoatxu0untvf; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY subdepartments
ADD CONSTRAINT fk_er03pwih7shyvcoatxu0untvf FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: amount_units fk_gfqwxy9v5jdcxp5ldekofktxj; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY amount_units
ADD CONSTRAINT fk_gfqwxy9v5jdcxp5ldekofktxj FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: finances fk_hrx0g6s871374bq150mjl6lul; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finances
ADD CONSTRAINT fk_hrx0g6s871374bq150mjl6lul FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: suppliers fk_hwq1en4ch8qvphsxf9lwej0fg; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY suppliers
ADD CONSTRAINT fk_hwq1en4ch8qvphsxf9lwej0fg FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: institutes fk_irv2623eqwi2icti2ebqmfnth; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY institutes
ADD CONSTRAINT fk_irv2623eqwi2icti2ebqmfnth FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: finance_dep fk_kcvkj7rnc090xavcgxed3wu13; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finance_dep
ADD CONSTRAINT fk_kcvkj7rnc090xavcgxed3wu13 FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: producers fk_ku4mlwdnyx7kwbmymvmusspcf; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY producers
ADD CONSTRAINT fk_ku4mlwdnyx7kwbmymvmusspcf FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: employees fk_l30in7eku2ecbukdy7mkg08i9; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY employees
ADD CONSTRAINT fk_l30in7eku2ecbukdy7mkg08i9 FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: departments fk_lesoxdijnp38bjbjw904wu43v; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY departments
ADD CONSTRAINT fk_lesoxdijnp38bjbjw904wu43v FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: amount_units fk_ll8tf0b5oltd31ohhtpobc32e; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY amount_units
ADD CONSTRAINT fk_ll8tf0b5oltd31ohhtpobc32e FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: producers fk_ownfq9y1sbvs58u39bjxmuli9; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY producers
ADD CONSTRAINT fk_ownfq9y1sbvs58u39bjxmuli9 FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: departments fk_p6m3fphbw29hv03o3cubeji1e; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY departments
ADD CONSTRAINT fk_p6m3fphbw29hv03o3cubeji1e FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: bids fk_sa983s0v7kmy5nqrpa4q79qsw; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fk_sa983s0v7kmy5nqrpa4q79qsw FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: bid_statuses fk_so0yugpnbs5r34p9yuvy88w93; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bid_statuses
ADD CONSTRAINT fk_so0yugpnbs5r34p9yuvy88w93 FOREIGN KEY (modified_by) REFERENCES employees(id);
--
-- Name: bid_statuses fk_t4ptdaybdtml52sl5llarqyd4; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bid_statuses
ADD CONSTRAINT fk_t4ptdaybdtml52sl5llarqyd4 FOREIGN KEY (created_by) REFERENCES employees(id);
--
-- Name: bids fkcy5ui58j8edka48hh05f7jc26; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fkcy5ui58j8edka48hh05f7jc26 FOREIGN KEY (finance_dep_id) REFERENCES finance_dep(id);
--
-- Name: bid_statuses fkdardqbah9kkqa1u5ywcpje662; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bid_statuses
ADD CONSTRAINT fkdardqbah9kkqa1u5ywcpje662 FOREIGN KEY (bid_id) REFERENCES bids(id);
--
-- Name: finance_dep fke1f3b0agx8mlhajv4sw2shbpp; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY finance_dep
ADD CONSTRAINT fke1f3b0agx8mlhajv4sw2shbpp FOREIGN KEY (finance_id) REFERENCES finances(id);
--
-- Name: bids fkf5o6dvp3q0iltpx4u2dau7t8r; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fkf5o6dvp3q0iltpx4u2dau7t8r FOREIGN KEY (cpv_code) REFERENCES cpv(cpv_code);
--
-- Name: bids fkipt88thl0kj9c09jo80dun9g9; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fkipt88thl0kj9c09jo80dun9g9 FOREIGN KEY (producer_id) REFERENCES producers(id);
--
-- Name: departments fkn8e2nupe8aik8xwqad6b5furs; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY departments
ADD CONSTRAINT fkn8e2nupe8aik8xwqad6b5furs FOREIGN KEY (inst_id) REFERENCES institutes(id);
--
-- Name: subdepartments fkr4pqpc6g3gd4y1dyjnts36pmo; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY subdepartments
ADD CONSTRAINT fkr4pqpc6g3gd4y1dyjnts36pmo FOREIGN KEY (dep_id) REFERENCES departments(id);
--
-- Name: bids fkth8arq3mim7mm402mv93j21ps; Type: FK CONSTRAINT; Schema: promasy; Owner: postgres
--
ALTER TABLE ONLY bids
ADD CONSTRAINT fkth8arq3mim7mm402mv93j21ps FOREIGN KEY (am_unit_id) REFERENCES amount_units(id);
--
-- If user 'promasy_user' do not exists - creating it
--
DO
$body$
BEGIN
IF NOT EXISTS (
SELECT *
FROM pg_catalog.pg_user
WHERE usename = 'promasy_user') THEN
CREATE ROLE promasy_user LOGIN ENCRYPTED PASSWORD '@ccessp@ss';
END IF;
END
$body$;
--
-- Name: promasy; Type: ACL; Schema: -; Owner: postgres
--
GRANT USAGE ON SCHEMA promasy TO promasy_user;
--
-- Name: amount_units; Type: ACL; Schema: promasy; Owner: postgres
--
GRANT SELECT,INSERT,UPDATE ON TABLE amount_units TO promasy_user;
--
-- Name: bid_statuses; Type: ACL; Schema: promasy; Owner: postgres
--
GRANT SELECT,INSERT,UPDATE ON TABLE bid_statuses TO promasy_user;
--
-- Name: bids; Type: ACL; Schema: promasy; Owner: postgres
--
GRANT SELECT,INSERT,UPDATE ON TABLE bids TO promasy_user;
--
-- Name: cpv; Type: ACL; Schema: promasy; Owner: postgres
--
GRANT SELECT,INSERT,UPDATE ON TABLE cpv TO promasy_user;
--
-- Name: departments; Type: ACL; Schema: promasy; Owner: postgres
--
GRANT SELECT,INSERT,UPDATE ON TABLE departments TO promasy_user;
--
-- Name: employees; Type: ACL; Schema: promasy; Owner: postgres