-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path01_modular_base.sql
More file actions
864 lines (605 loc) · 27.9 KB
/
01_modular_base.sql
File metadata and controls
864 lines (605 loc) · 27.9 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
--
-- TOC entry 292 (class 1259 OID 21003)
-- Name: claim_ClaimAttachment; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."claim_ClaimAttachment" (
"id" "uuid" NOT NULL,
"ValidityFrom" timestamp with time zone NOT NULL,
"ValidityTo" timestamp with time zone,
"LegacyID" "uuid",
"type" "text",
"title" "text",
"date" "date",
"filename" "text",
"mime" "text",
"url" "text",
"document" "text",
"claim_id" integer NOT NULL
);
-- ALTER TABLE "public"."claim_ClaimAttachment" OWNER TO "postgres";
--
-- TOC entry 339 (class 1259 OID 21734)
-- Name: claim_ClaimAttachmentsCountView; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW "public"."claim_ClaimAttachmentsCountView" AS
SELECT "claim_ClaimAttachment"."claim_id",
"count"(*) AS "attachments_count"
FROM "public"."claim_ClaimAttachment"
GROUP BY "claim_ClaimAttachment"."claim_id";
-- ALTER TABLE "public"."claim_ClaimAttachmentsCountView" OWNER TO "postgres";
--
-- TOC entry 297 (class 1259 OID 21030)
-- Name: claim_ClaimMutation; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."claim_ClaimMutation" (
"id" "uuid" NOT NULL,
"claim_id" integer NOT NULL,
"mutation_id" "uuid" NOT NULL
);
-- ALTER TABLE "public"."claim_ClaimMutation" OWNER TO "postgres";
--
-- TOC entry 245 (class 1259 OID 20558)
-- Name: location_HealthFacilityMutation; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."location_HealthFacilityMutation" (
"id" "uuid" NOT NULL,
"health_facility_id" integer NOT NULL,
"mutation_id" "uuid" NOT NULL
);
-- ALTER TABLE "public"."location_HealthFacilityMutation" OWNER TO "postgres";
--
-- TOC entry 249 (class 1259 OID 20578)
-- Name: location_LocationMutation; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."location_LocationMutation" (
"id" "uuid" NOT NULL,
"location_id" integer NOT NULL,
"mutation_id" "uuid" NOT NULL
);
-- ALTER TABLE "public"."location_LocationMutation" OWNER TO "postgres";
--
-- TOC entry 308 (class 1259 OID 21358)
-- Name: report_ReportDefinition; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."report_ReportDefinition" (
"id" "uuid" NOT NULL,
"name" character varying(255) NOT NULL,
"engine" integer NOT NULL,
"definition" "text" NOT NULL,
"validity_from" timestamp with time zone,
"validity_to" timestamp with time zone
);
--
-- TOC entry 215 (class 1259 OID 20305)
-- Name: core_FieldControl; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."core_FieldControl" (
"id" "uuid" NOT NULL,
"field" character varying(250) NOT NULL,
"usage" integer,
"module_id" "uuid" NOT NULL
);
-- ALTER TABLE "public"."core_FieldControl" OWNER TO "postgres";
--
-- TOC entry 219 (class 1259 OID 20330)
-- Name: core_ModuleConfiguration; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."core_ModuleConfiguration" (
"id" "uuid" NOT NULL,
"module" character varying(20) NOT NULL,
"layer" character varying(2) NOT NULL,
"version" character varying(10) NOT NULL,
"config" "text" NOT NULL,
"is_exposed" boolean NOT NULL,
"is_disabled_until" timestamp with time zone
);
-- ALTER TABLE "public"."core_ModuleConfiguration" OWNER TO "postgres";
--
-- TOC entry 220 (class 1259 OID 20338)
-- Name: core_Mutation_Log; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."core_Mutation_Log" (
"id" "uuid" NOT NULL,
"json_content" "text" NOT NULL,
"request_date_time" timestamp with time zone NOT NULL,
"client_mutation_id" character varying(255),
"client_mutation_label" character varying(255),
"client_mutation_details" "text",
"status" integer NOT NULL,
"error" "text",
"user_id" "uuid"
);
-- ALTER TABLE "public"."core_Mutation_Log" OWNER TO "postgres";
--
-- TOC entry 227 (class 1259 OID 20372)
-- Name: core_TechnicalUser; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."core_TechnicalUser" (
"password" character varying(128) NOT NULL,
"last_login" timestamp with time zone,
"id" "uuid" NOT NULL,
"username" character varying(150) NOT NULL,
"email" character varying(254),
"is_staff" boolean NOT NULL,
"is_superuser" boolean NOT NULL,
"validity_from" timestamp with time zone,
"validity_to" timestamp with time zone
);
-- ALTER TABLE "public"."core_TechnicalUser" OWNER TO "postgres";
--
-- TOC entry 212 (class 1259 OID 20290)
-- Name: core_User; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."core_User" (
"id" "uuid" NOT NULL,
"username" character varying(25) NOT NULL,
"i_user_id" integer,
"t_user_id" "uuid",
claim_admin_id integer,
officer_id integer,
"LegacyID" "uuid",
"ValidityFrom" timestamp with time zone NOT NULL,
"ValidityTo" timestamp with time zone
);
-- ALTER TABLE "public"."core_User" OWNER TO "postgres";
--
-- TOC entry 214 (class 1259 OID 20299)
-- Name: Core_User_groups_tbl; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."Core_User_groups_tbl" (
"id" integer NOT NULL,
"user_id" "uuid" NOT NULL,
"group_id" integer NOT NULL
);
-- ALTER TABLE "public"."Core_User_groups_tbl" OWNER TO "postgres";
--
-- TOC entry 213 (class 1259 OID 20297)
-- Name: Core_User_groups_tbl_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "public"."Core_User_groups_tbl_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
-- ALTER TABLE "public"."Core_User_groups_tbl_id_seq" OWNER TO "postgres";
--
-- TOC entry 3994 (class 0 OID 0)
-- Dependencies: 213
-- Name: Core_User_groups_tbl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "public"."Core_User_groups_tbl_id_seq" OWNED BY "public"."Core_User_groups_tbl"."id";
--
-- TOC entry 231 (class 1259 OID 20392)
-- Name: core_User_user_permissions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."core_User_user_permissions" (
"id" integer NOT NULL,
"user_id" "uuid" NOT NULL,
"permission_id" integer NOT NULL
);
-- ALTER TABLE "public"."core_User_user_permissions" OWNER TO "postgres";
--
-- TOC entry 230 (class 1259 OID 20390)
-- Name: core_User_user_permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "public"."core_User_user_permissions_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
-- ALTER TABLE "public"."core_User_user_permissions_id_seq" OWNER TO "postgres";
--
-- TOC entry 3995 (class 0 OID 0)
-- Dependencies: 230
-- Name: core_User_user_permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "public"."core_User_user_permissions_id_seq" OWNED BY "public"."core_User_user_permissions"."id";
-- SECTION mutations
create table "public"."core_UserMutation"
(
id uuid primary key,
core_user_id "uuid" not null,
mutation_id uuid not null
);
create index "core_UserMutation_mutation_id_10b94d76"
on "public"."core_UserMutation" (mutation_id);
create index "core_UserMutation_core_user_id_12d89786"
on "public"."core_UserMutation" (core_user_id);
create table "public"."insuree_FamilyMutation"
(
id uuid primary key,
family_id integer not null,
mutation_id uuid not null
);
create index "insuree_FamilyMutation_mutation_id_10b94d76"
on "public"."insuree_FamilyMutation" (mutation_id);
create index "insuree_FamilyMutation_family_id_12d89786"
on "public"."insuree_FamilyMutation" (family_id);
create table "public"."insuree_InsureeMutation"
(
id uuid primary key,
insuree_id integer not null,
mutation_id uuid not null
);
create index "insuree_InsureeMutation_mutation_id_88cab16e"
on "public"."insuree_InsureeMutation" (mutation_id);
create index "insuree_InsureeMutation_insuree_id_d9f5ddbd"
on "public"."insuree_InsureeMutation" (insuree_id);
-- create table "insuree_batch_InsureeBatchMutation"
-- (
-- id uuid primary key,
-- insuree_batch_id integer not null,
-- mutation_id uuid not null
-- );
--
--
-- create index "insuree_batch_InsureeBatchMutation_mutation_id_d2502256"
-- on "insuree_InsureeMutation" (mutation_id);
--
-- create index "insuree_batch_InsureeBatchMutation_insuree_batch_id_ae5ea5f0"
-- on "insuree_batch_insureebatch" (insuree_batch_id);
--
-- TOC entry 3633 (class 2606 OID 21010)
-- Name: claim_ClaimAttachment claim_ClaimAttachment_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."claim_ClaimAttachment"
ADD CONSTRAINT "claim_ClaimAttachment_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3648 (class 2606 OID 21034)
-- Name: claim_ClaimMutation claim_ClaimMutation_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."claim_ClaimMutation"
ADD CONSTRAINT "claim_ClaimMutation_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3408 (class 2606 OID 20311)
-- Name: core_FieldControl core_FieldControl_field_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_FieldControl"
ADD CONSTRAINT "core_FieldControl_field_key" UNIQUE ("field");
--
-- TOC entry 3411 (class 2606 OID 20309)
-- Name: core_FieldControl core_FieldControl_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_FieldControl"
ADD CONSTRAINT "core_FieldControl_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3423 (class 2606 OID 20337)
-- Name: core_ModuleConfiguration core_ModuleConfiguration_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_ModuleConfiguration"
ADD CONSTRAINT "core_ModuleConfiguration_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3425 (class 2606 OID 20345)
-- Name: core_Mutation_Log core_Mutation_Log_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_Mutation_Log"
ADD CONSTRAINT "core_Mutation_Log_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3439 (class 2606 OID 20379)
-- Name: core_TechnicalUser core_TechnicalUser_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_TechnicalUser"
ADD CONSTRAINT "core_TechnicalUser_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3442 (class 2606 OID 20381)
-- Name: core_TechnicalUser core_TechnicalUser_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_TechnicalUser"
ADD CONSTRAINT "core_TechnicalUser_username_key" UNIQUE ("username");
--
-- TOC entry 3402 (class 2606 OID 20304)
-- Name: Core_User_groups_tbl Core_User_groups_tbl_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."Core_User_groups_tbl"
ADD CONSTRAINT "Core_User_groups_tbl_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3405 (class 2606 OID 20410)
-- Name: Core_User_groups_tbl Core_User_groups_tbl_user_id_group_id_8ec5911a_uniq; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."Core_User_groups_tbl"
ADD CONSTRAINT "Core_User_groups_tbl_user_id_group_id_8ec5911a_uniq" UNIQUE ("user_id", "group_id");
--
-- TOC entry 3395 (class 2606 OID 20294)
-- Name: core_User core_User_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User"
ADD CONSTRAINT "core_User_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3449 (class 2606 OID 20397)
-- Name: core_User_user_permissions core_User_user_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User_user_permissions"
ADD CONSTRAINT "core_User_user_permissions_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3452 (class 2606 OID 20478)
-- Name: core_User_user_permissions core_User_user_permissions_user_id_permission_id_a3c26725_uniq; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User_user_permissions"
ADD CONSTRAINT "core_User_user_permissions_user_id_permission_id_a3c26725_uniq" UNIQUE ("user_id", "permission_id");
--
-- TOC entry 3399 (class 2606 OID 20296)
-- Name: core_User core_User_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User"
ADD CONSTRAINT "core_User_username_key" UNIQUE ("username");
--
-- TOC entry 3406 (class 1259 OID 20413)
-- Name: core_FieldControl_field_f7925479_like; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_FieldControl_field_f7925479_like" ON "public"."core_FieldControl" USING "btree" ("field" "varchar_pattern_ops");
--
-- TOC entry 3409 (class 1259 OID 20449)
-- Name: core_FieldControl_module_id_bc15aba5; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_FieldControl_module_id_bc15aba5" ON "public"."core_FieldControl" USING "btree" ("module_id");
--
-- TOC entry 3426 (class 1259 OID 20421)
-- Name: core_Mutation_Log_user_id_f2b2dc10; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_Mutation_Log_user_id_f2b2dc10" ON "public"."core_Mutation_Log" USING "btree" ("user_id");
--
-- TOC entry 3440 (class 1259 OID 20429)
-- Name: core_TechnicalUser_username_6f41c923_like; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_TechnicalUser_username_6f41c923_like" ON "public"."core_TechnicalUser" USING "btree" ("username" "varchar_pattern_ops");
--
-- TOC entry 3400 (class 1259 OID 20412)
-- Name: Core_User_groups_tbl_group_id_197830ae; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "Core_User_groups_tbl_group_id_197830ae" ON "public"."Core_User_groups_tbl" USING "btree" ("group_id");
--
-- TOC entry 3403 (class 1259 OID 20411)
-- Name: Core_User_groups_tbl_user_id_06a128ce; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "Core_User_groups_tbl_user_id_06a128ce" ON "public"."Core_User_groups_tbl" USING "btree" ("user_id");
--
-- TOC entry 3393 (class 1259 OID 20455)
-- Name: core_User_i_user_id_0537e04c; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_User_i_user_id_0537e04c" ON "public"."core_User" USING "btree" ("i_user_id");
CREATE INDEX "core_User_officer_id" ON "public"."core_User" USING "btree" ("officer_id");
CREATE INDEX "core_User_claim_admin_id" ON "public"."core_User" USING "btree" ("claim_admin_id");
--
-- TOC entry 3396 (class 1259 OID 20461)
-- Name: core_User_t_user_id_c850bf43; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_User_t_user_id_c850bf43" ON "public"."core_User" USING "btree" ("t_user_id");
--
-- TOC entry 3447 (class 1259 OID 20480)
-- Name: core_User_user_permissions_permission_id_f70a87da; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_User_user_permissions_permission_id_f70a87da" ON "public"."core_User_user_permissions" USING "btree" ("permission_id");
--
-- TOC entry 3450 (class 1259 OID 20479)
-- Name: core_User_user_permissions_user_id_bf794316; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_User_user_permissions_user_id_bf794316" ON "public"."core_User_user_permissions" USING "btree" ("user_id");
--
-- TOC entry 3397 (class 1259 OID 20398)
-- Name: core_User_username_109df633_like; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "core_User_username_109df633_like" ON "public"."core_User" USING "btree" ("username" "varchar_pattern_ops");
--
-- TOC entry 3799 (class 2606 OID 21158)
-- Name: claim_ClaimAttachment claim_ClaimAttachment_claim_id_6d421217_fk_tblClaim_ClaimID; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."claim_ClaimAttachment"
ADD CONSTRAINT "claim_ClaimAttachment_claim_id_6d421217_fk_tblClaim_ClaimID" FOREIGN KEY ("claim_id") REFERENCES "public"."tblClaim"("ClaimID") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3808 (class 2606 OID 21104)
-- Name: claim_ClaimMutation claim_ClaimMutation_claim_id_22e307c0_fk_tblClaim_ClaimID; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."claim_ClaimMutation"
ADD CONSTRAINT "claim_ClaimMutation_claim_id_22e307c0_fk_tblClaim_ClaimID" FOREIGN KEY ("claim_id") REFERENCES "public"."tblClaim"("ClaimID") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3807 (class 2606 OID 21110)
-- Name: claim_ClaimMutation claim_ClaimMutation_mutation_id_6492ecd0_fk_core_Muta; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."claim_ClaimMutation"
ADD CONSTRAINT "claim_ClaimMutation_mutation_id_6492ecd0_fk_core_Muta" FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3729 (class 2606 OID 20450)
-- Name: core_FieldControl core_FieldControl_module_id_bc15aba5_fk_core_Modu; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_FieldControl"
ADD CONSTRAINT "core_FieldControl_module_id_bc15aba5_fk_core_Modu" FOREIGN KEY ("module_id") REFERENCES "public"."core_ModuleConfiguration"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3731 (class 2606 OID 20416)
-- Name: core_Mutation_Log core_Mutation_Log_user_id_f2b2dc10_fk_core_User_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_Mutation_Log"
ADD CONSTRAINT "core_Mutation_Log_user_id_f2b2dc10_fk_core_User_id" FOREIGN KEY ("user_id") REFERENCES "public"."core_User"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3727 (class 2606 OID 20399)
-- Name: Core_User_groups_tbl Core_User_groups_tbl_user_id_06a128ce_fk_core_User_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."Core_User_groups_tbl"
ADD CONSTRAINT "Core_User_groups_tbl_user_id_06a128ce_fk_core_User_id" FOREIGN KEY ("user_id") REFERENCES "public"."core_User"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3725 (class 2606 OID 20456)
-- Name: core_User core_User_i_user_id_0537e04c_fk_tblUsers_UserID; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User"
ADD CONSTRAINT "core_User_i_user_id_0537e04c_fk_tblUsers_UserID" FOREIGN KEY ("i_user_id") REFERENCES "public"."tblUsers"("UserID") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3726 (class 2606 OID 20462)
-- Name: core_User core_User_t_user_id_c850bf43_fk_core_TechnicalUser_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User"
ADD CONSTRAINT "core_User_t_user_id_c850bf43_fk_core_TechnicalUser_id" FOREIGN KEY ("t_user_id") REFERENCES "public"."core_TechnicalUser"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3737 (class 2606 OID 20467)
-- Name: core_User_user_permissions core_User_user_permissions_user_id_bf794316_fk_core_User_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User_user_permissions"
ADD CONSTRAINT "core_User_user_permissions_user_id_bf794316_fk_core_User_id" FOREIGN KEY ("user_id") REFERENCES "public"."core_User"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3749 (class 2606 OID 20599)
-- Name: location_HealthFacilityMutation location_HealthFacil_health_facility_id_c99eb971_fk_tblHF_HfI; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."location_HealthFacilityMutation"
ADD CONSTRAINT "location_HealthFacil_health_facility_id_c99eb971_fk_tblHF_HfI" FOREIGN KEY ("health_facility_id") REFERENCES "public"."tblHF"("HfID") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3748 (class 2606 OID 20604)
-- Name: location_HealthFacilityMutation location_HealthFacil_mutation_id_8c14c145_fk_core_Muta; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."location_HealthFacilityMutation"
ADD CONSTRAINT "location_HealthFacil_mutation_id_8c14c145_fk_core_Muta" FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3752 (class 2606 OID 20619)
-- Name: location_LocationMutation location_LocationMut_location_id_4a54c595_fk_tblLocati; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."location_LocationMutation"
ADD CONSTRAINT "location_LocationMut_location_id_4a54c595_fk_tblLocati" FOREIGN KEY ("location_id") REFERENCES "public"."tblLocations"("LocationId") DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3751 (class 2606 OID 20624)
-- Name: location_LocationMutation location_LocationMut_mutation_id_299edb4e_fk_core_Muta; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."location_LocationMutation"
ADD CONSTRAINT "location_LocationMut_mutation_id_299edb4e_fk_core_Muta" FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id") DEFERRABLE INITIALLY DEFERRED;
-- TODO
-- ALTER TABLE ONLY "public"."core_UserMutation"
-- ADD CONSTRAINT "FK_core_UserMutation_core_user_id"
-- FOREIGN KEY ("core_user_id") REFERENCES "public"."core_User"("id")
-- DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY "public"."core_UserMutation"
ADD CONSTRAINT "FK_core_UserMutation_core_Mutation_Log_id"
FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id")
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY "public"."insuree_FamilyMutation"
ADD CONSTRAINT "FK_insuree_FamilyMutation_tblFamilies_FamilyID"
FOREIGN KEY ("family_id") REFERENCES "public"."tblFamilies"("FamilyID")
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY "public"."insuree_FamilyMutation"
ADD CONSTRAINT "FK_insuree_FamilyMutation_core_Mutation_Log_id"
FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id")
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY "public"."insuree_InsureeMutation"
ADD CONSTRAINT "FK_insuree_InsureeMutation_tblInsuree_InsureeID"
FOREIGN KEY ("insuree_id") REFERENCES "public"."tblInsuree"("InsureeID")
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY "public"."insuree_InsureeMutation"
ADD CONSTRAINT "FK_insuree_InsureeMutation_core_Mutation_Log_id"
FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id")
DEFERRABLE INITIALLY DEFERRED;
-- ALTER TABLE ONLY "public"."insuree_batch_InsureeBatchMutation"
-- ADD CONSTRAINT "FK_insuree_batch_InsureeBatchMutation_insuree_batch"
-- FOREIGN KEY ("insuree_batch_id") REFERENCES "public"."insuree_batch_insureebatch"("insuree_batch_id")
-- DEFERRABLE INITIALLY DEFERRED;
-- ALTER TABLE ONLY "public"."insuree_batch_InsureeBatchMutation"
-- ADD CONSTRAINT "FK_insuree_batch_InsureeBatchMutation_core_Mutation_Log_id"
-- FOREIGN KEY ("mutation_id") REFERENCES "public"."core_Mutation_Log"("id")
-- DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3329 (class 2604 OID 20302)
-- Name: Core_User_groups_tbl id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."Core_User_groups_tbl" ALTER COLUMN "id" SET DEFAULT "nextval"('"public"."Core_User_groups_tbl_id_seq"'::"regclass");
--
-- TOC entry 3335 (class 2604 OID 20395)
-- Name: core_User_user_permissions id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."core_User_user_permissions" ALTER COLUMN "id" SET DEFAULT "nextval"('"public"."core_User_user_permissions_id_seq"'::"regclass");
--
-- TOC entry 3491 (class 2606 OID 20562)
-- Name: location_HealthFacilityMutation location_HealthFacilityMutation_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."location_HealthFacilityMutation"
ADD CONSTRAINT "location_HealthFacilityMutation_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3504 (class 2606 OID 20582)
-- Name: location_LocationMutation location_LocationMutation_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."location_LocationMutation"
ADD CONSTRAINT "location_LocationMutation_pkey" PRIMARY KEY ("id");
--
-- TOC entry 3631 (class 1259 OID 21157)
-- Name: claim_ClaimAttachment_claim_id_6d421217; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "claim_ClaimAttachment_claim_id_6d421217" ON "public"."claim_ClaimAttachment" USING "btree" ("claim_id");
--
-- TOC entry 3645 (class 1259 OID 21103)
-- Name: claim_ClaimMutation_claim_id_22e307c0; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "claim_ClaimMutation_claim_id_22e307c0" ON "public"."claim_ClaimMutation" USING "btree" ("claim_id");
--
-- TOC entry 3646 (class 1259 OID 21109)
-- Name: claim_ClaimMutation_mutation_id_6492ecd0; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "claim_ClaimMutation_mutation_id_6492ecd0" ON "public"."claim_ClaimMutation" USING "btree" ("mutation_id");
--
-- TOC entry 3488 (class 1259 OID 20609)
-- Name: location_HealthFacilityMutation_health_facility_id_c99eb971; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "location_HealthFacilityMutation_health_facility_id_c99eb971" ON "public"."location_HealthFacilityMutation" USING "btree" ("health_facility_id");
--
-- TOC entry 3489 (class 1259 OID 20610)
-- Name: location_HealthFacilityMutation_mutation_id_8c14c145; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "location_HealthFacilityMutation_mutation_id_8c14c145" ON "public"."location_HealthFacilityMutation" USING "btree" ("mutation_id");
--
-- TOC entry 3501 (class 1259 OID 20629)
-- Name: location_LocationMutation_location_id_4a54c595; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "location_LocationMutation_location_id_4a54c595" ON "public"."location_LocationMutation" USING "btree" ("location_id");
--
-- TOC entry 3502 (class 1259 OID 20630)
-- Name: location_LocationMutation_mutation_id_299edb4e; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "location_LocationMutation_mutation_id_299edb4e" ON "public"."location_LocationMutation" USING "btree" ("mutation_id");
--
-- TOC entry 3677 (class 1259 OID 21368)
-- Name: report_ReportDefinition_name_5246bc7a_like; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "report_ReportDefinition_name_5246bc7a_like" ON "public"."report_ReportDefinition" USING "btree" ("name" "varchar_pattern_ops");
--
-- TOC entry 3681 (class 2606 OID 21365)
-- Name: report_ReportDefinition report_ReportDefinition_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."report_ReportDefinition"
ADD CONSTRAINT "report_ReportDefinition_pkey" PRIMARY KEY ("id");
--
-- TOC entry 307 (class 1259 OID 21276)
-- Name: health_check_db_testmodel; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "public"."health_check_db_testmodel" (
"id" integer NOT NULL,
"title" character varying(128) NOT NULL
);
-- ALTER TABLE "public"."health_check_db_testmodel" OWNER TO "postgres";
--
-- TOC entry 306 (class 1259 OID 21274)
-- Name: health_check_db_testmodel_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "public"."health_check_db_testmodel_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
-- ALTER TABLE "public"."health_check_db_testmodel_id_seq" OWNER TO "postgres";
--
-- TOC entry 3999 (class 0 OID 0)
-- Dependencies: 306
-- Name: health_check_db_testmodel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "public"."health_check_db_testmodel_id_seq" OWNED BY "public"."health_check_db_testmodel"."id";
--
-- TOC entry 3368 (class 2604 OID 21279)
-- Name: health_check_db_testmodel id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."health_check_db_testmodel" ALTER COLUMN "id" SET DEFAULT "nextval"('"public"."health_check_db_testmodel_id_seq"'::"regclass");
--
-- TOC entry 3676 (class 2606 OID 21281)
-- Name: health_check_db_testmodel health_check_db_testmodel_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "public"."health_check_db_testmodel"
ADD CONSTRAINT "health_check_db_testmodel_pkey" PRIMARY KEY ("id");
CREATE OR REPLACE VIEW "public"."claim_ClaimAttachmentsCountView" AS
select "claim_id", count(*) "attachments_count" from "claim_ClaimAttachment" GROUP BY "claim_id"
;