-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDatabaseSchemaUpdates.txt
1082 lines (907 loc) · 34.4 KB
/
DatabaseSchemaUpdates.txt
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
9/3/2016
-- Table: time_category
-- DROP TABLE time_category;
CREATE TABLE time_category
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
CONSTRAINT time_category_pkey PRIMARY KEY (id),
CONSTRAINT time_category_title_unique UNIQUE (title)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE time_category
OWNER TO postgres;
ALTER TABLE "time"
ADD COLUMN time_category_id integer;
ALTER TABLE "time"
ADD CONSTRAINT "FK_time_category_TimeCategoryId" FOREIGN KEY (time_category_id) REFERENCES time_category (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
4/10/2016
-- Table: asset
-- DROP TABLE asset;
CREATE TABLE asset
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
id_int bigserial NOT NULL,
date timestamp without time zone NOT NULL,
title text NOT NULL,
is_final boolean NOT NULL,
is_court_filed boolean NOT NULL,
is_attorney_work_product boolean NOT NULL,
is_privileged boolean NOT NULL,
is_discoverable boolean NOT NULL,
provided_in_discovery_at timestamp without time zone,
checked_out_by_id uuid,
checked_out_at timestamp without time zone,
CONSTRAINT assets_pkey PRIMARY KEY (id),
CONSTRAINT "FK_asset_checked_out_by_users_id" FOREIGN KEY (checked_out_by_id)
REFERENCES "Users" ("pId") MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE asset
OWNER TO postgres;
-- Table: version
-- DROP TABLE version;
CREATE TABLE version
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
sequence_number integer NOT NULL,
change_details text,
asset_id uuid NOT NULL,
CONSTRAINT version_pkey PRIMARY KEY (id),
CONSTRAINT "FK_version_asset_id_asset_id" FOREIGN KEY (asset_id)
REFERENCES asset (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE version
OWNER TO postgres;
-- Table: file
-- DROP TABLE file;
CREATE TABLE file
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
version_id uuid NOT NULL,
is_source boolean NOT NULL,
content_length bigint NOT NULL,
content_type text NOT NULL,
extension text,
CONSTRAINT file_pkey PRIMARY KEY (id),
CONSTRAINT "FK_file_version_id_version_id" FOREIGN KEY (version_id)
REFERENCES version (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE file
OWNER TO postgres;
-- Table: asset_matter
-- DROP TABLE asset_matter;
CREATE TABLE asset_matter
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
asset_id uuid NOT NULL,
matter_id uuid NOT NULL,
CONSTRAINT pkey_asset_matter PRIMARY KEY (id),
CONSTRAINT "FK_asset_matter_asset_id_asset_id" FOREIGN KEY (asset_id)
REFERENCES asset (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_asset_matter_matter_id_matter_id" FOREIGN KEY (matter_id)
REFERENCES matter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE asset_matter
OWNER TO postgres;
-- Table: asset_tag
-- DROP TABLE asset_tag;
CREATE TABLE asset_tag
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
name text NOT NULL,
CONSTRAINT asset_tag_pkey PRIMARY KEY (id),
CONSTRAINT asset_tag_name_unique UNIQUE (name)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE asset_tag
OWNER TO postgres;
-- Table: asset_asset_tag
-- DROP TABLE asset_asset_tag;
CREATE TABLE asset_asset_tag
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
asset_id uuid NOT NULL,
asset_tag_id integer NOT NULL,
CONSTRAINT asset_asset_tag_pkey PRIMARY KEY (id),
CONSTRAINT "FK_asset_asset_tag_asset_id" FOREIGN KEY (asset_id)
REFERENCES asset (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_asset_asset_tag_asset_tag_id" FOREIGN KEY (asset_tag_id)
REFERENCES asset_tag (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE asset_asset_tag
OWNER TO postgres;
2/21/2016
-- Events are no longer supported - May look to Office 365 in the future
DROP TABLE event_assigned_contact;
DROP TABLE event_matter;
DROP TABLE event_note;
DROP TABLE event_tag;
DROP TABLE event_task;
DROP TABLE event;
-- Forms are no longer supported - HotDocs can access the database
DROP TABLE form_field_matter;
DROP TABLE form_field;
DROP TABLE form;
-- Tags are no longer supported - in use they were useless - waste of time
DROP TABLE matter_tag;
DROP TABLE task_tag;
DROP TABLE tag_category;
DROP TABLE tag_filter;
-- Documents are no longer supported - needs redesigned for better OS integration - may be impelemented in the future
DROP TABLE document_task;
DROP TABLE document_matter;
DROP TABLE version;
DROP TABLE document;
1/1/2016
ALTER TABLE matter
DROP COLUMN lead_attorney_contact_id;
ALTER TABLE matter_contact
DROP COLUMN role;
12/27/2015
UPDATE matter_contact SET "is_attorney"=TRUE WHERE LOWER("role") LIKE LOWER('%attorney%');
UPDATE matter_contact SET "is_lead_attorney"=TRUE WHERE LOWER("role") LIKE LOWER('%lead attorney%');
UPDATE matter_contact SET "is_client"=TRUE WHERE LOWER("role") LIKE LOWER('client');
UPDATE matter_contact SET "is_client_contact"=TRUE WHERE LOWER("role") LIKE LOWER('%client contact%');
UPDATE matter_contact SET "is_appointed"=TRUE WHERE LOWER("role") LIKE LOWER('%appointed client%');
-- Table: court_type
-- DROP TABLE court_type;
CREATE TABLE court_type
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
CONSTRAINT court_type_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE court_type
OWNER TO postgres;
-- Table: court_geographical_jurisdiction
-- DROP TABLE court_geographical_jurisdiction;
CREATE TABLE court_geographical_jurisdiction
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
CONSTRAINT court_geographical_jurisdiction_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE court_geographical_jurisdiction
OWNER TO postgres;
-- Table: court_sitting_in_city
-- DROP TABLE court_sitting_in_city;
CREATE TABLE court_sitting_in_city
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
CONSTRAINT court_sitting_in_city_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE court_sitting_in_city
OWNER TO postgres;
ALTER TABLE matter
DROP COLUMN jurisdiction;
ALTER TABLE matter
ADD COLUMN attorney_for_party_title text;
ALTER TABLE matter
ADD COLUMN court_type_id integer;
ALTER TABLE matter
ADD COLUMN court_geographical_jurisdiction_id integer;
ALTER TABLE matter
ADD COLUMN court_sitting_in_city_id integer;
ALTER TABLE matter
ADD COLUMN caption_plaintiff_or_subject_short text;
ALTER TABLE matter
ADD COLUMN caption_plaintiff_or_subject_regular text;
ALTER TABLE matter
ADD COLUMN caption_plaintiff_or_subject_long text;
ALTER TABLE matter
ADD COLUMN caption_other_party_short text;
ALTER TABLE matter
ADD COLUMN caption_other_party_regular text;
ALTER TABLE matter
ADD COLUMN caption_other_party_long text;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_court_type_CourtTypeId" FOREIGN KEY (court_type_id) REFERENCES court_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_court_geographical_jurisdiction_CourtGeographicalJurisdictionId" FOREIGN KEY (court_geographical_jurisdiction_id) REFERENCES court_geographical_jurisdiction (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_court_sitting_in_city_CourtSittingInCityId" FOREIGN KEY (court_sitting_in_city_id) REFERENCES court_sitting_in_city (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
12/26/2015
DROP TABLE event_responsible_user;
DROP TABLE task_responsible_user;
DROP TABLE responsible_user;
ALTER TABLE contact
ADD COLUMN address1_address_line2 text;
ALTER TABLE contact
ADD COLUMN address2_address_line2 text;
ALTER TABLE contact
ADD COLUMN address3_address_line2 text;
ALTER TABLE contact
ADD COLUMN bar_number text;
ALTER TABLE matter_contact
ADD COLUMN is_client boolean;
ALTER TABLE matter_contact
ADD COLUMN is_client_contact boolean;
ALTER TABLE matter_contact
ADD COLUMN is_appointed boolean;
ALTER TABLE matter_contact
ADD COLUMN is_party boolean;
ALTER TABLE matter_contact
ADD COLUMN party_title text;
ALTER TABLE matter_contact
ADD COLUMN is_judge boolean;
ALTER TABLE matter_contact
ADD COLUMN is_witness boolean;
ALTER TABLE matter_contact
ADD COLUMN is_attorney boolean;
ALTER TABLE matter_contact
ADD COLUMN attorney_for_contact_id integer;
ALTER TABLE matter_contact
ADD COLUMN is_lead_attorney boolean;
ALTER TABLE matter_contact
ADD COLUMN is_support_staff boolean;
ALTER TABLE matter_contact
ADD COLUMN support_staff_for_contact_id integer;
ALTER TABLE matter_contact
ADD COLUMN is_third_party_payor boolean;
ALTER TABLE matter_contact
ADD COLUMN third_party_payor_for_contact_id integer;
ALTER TABLE matter_contact
ADD CONSTRAINT "FK_matter_contact_contact_AttorneyForContactId" FOREIGN KEY (attorney_for_contact_id) REFERENCES contact (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter_contact
ADD CONSTRAINT "FK_matter_contact_contact_SupportStaffForContactId" FOREIGN KEY (support_staff_for_contact_id) REFERENCES contact (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter_contact
ADD CONSTRAINT "FK_matter_contact_contact_ThirdPartyPayorForContactId" FOREIGN KEY (third_party_payor_for_contact_id) REFERENCES contact (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter
ADD COLUMN id_int bigserial NOT NULL;
5/25/2015
-- Table: task_template
-- DROP TABLE task_template;
CREATE TABLE task_template
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
task_template_title text NOT NULL,
title text,
description text,
active boolean NOT NULL,
projected_start text,
due_date text,
actual_end text,
projected_end text,
CONSTRAINT task_template_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE task_template
OWNER TO postgres;
5/24/2015
-- Table: note_notification
-- DROP TABLE note_notification;
CREATE TABLE note_notification
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
contact_id integer NOT NULL,
note_id uuid NOT NULL,
cleared timestamp without time zone,
CONSTRAINT note_notification_pkey PRIMARY KEY (id),
CONSTRAINT "note_notification_contact_ContactId" FOREIGN KEY (contact_id)
REFERENCES contact (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "note_notification_note_NoteId" FOREIGN KEY (note_id)
REFERENCES note (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE note_notification
OWNER TO postgres;
4/27/2015
-- Table: form
-- DROP TABLE form;
CREATE TABLE form
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
matter_type_id integer NOT NULL,
path text NOT NULL,
CONSTRAINT form_pkey PRIMARY KEY (id),
CONSTRAINT "form_matter_type_MatterTypeId_Id" FOREIGN KEY (matter_type_id)
REFERENCES matter_type (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE form
OWNER TO postgres;
4/26/2015
-- Table: matter_type
-- DROP TABLE matter_type;
CREATE TABLE matter_type
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
CONSTRAINT matter_type_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE matter_type
OWNER TO postgres;
ALTER TABLE matter
ADD COLUMN matter_type_id integer;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_matter_type_MatterTypeId_Id" FOREIGN KEY (matter_type_id) REFERENCES matter_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
4/2/2015 - 2
ALTER TABLE form_field_matter
ADD COLUMN value text;
4/2/2015
-- Table: form_field
-- DROP TABLE form_field;
CREATE TABLE form_field
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
description text,
CONSTRAINT "form_field_PK" PRIMARY KEY (id),
CONSTRAINT form_field_title_unique UNIQUE (title)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE form_field
OWNER TO postgres;
-- Table: form_field_matter
-- DROP TABLE form_field_matter;
CREATE TABLE form_field_matter
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
matter_id uuid NOT NULL,
form_field_id integer NOT NULL,
CONSTRAINT "form_field_matter_PK" PRIMARY KEY (id),
CONSTRAINT "form_field_matter_form_field_FormFieldId" FOREIGN KEY (form_field_id)
REFERENCES form_field (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "form_field_matter_matter_MatterId" FOREIGN KEY (matter_id)
REFERENCES matter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE form_field_matter
OWNER TO postgres;
2/28/2015
ALTER TABLE contact
ADD COLUMN billing_rate_id integer;
ALTER TABLE contact
ADD CONSTRAINT "FK_contact_billing_rate_BillingRateId" FOREIGN KEY (billing_rate_id) REFERENCES billing_rate (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_billing_group_BillingGroupId" FOREIGN KEY (billing_group_id) REFERENCES billing_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter
ADD COLUMN override_matter_rate_with_employee_rate boolean NOT NULL DEFAULT false;
2/20/2015
Changes to invoice
ALTER TABLE invoice
ADD COLUMN billing_group_id integer;
ALTER TABLE invoice
ADD CONSTRAINT "FK_invoice_billing_group_BillingGroupIp" FOREIGN KEY (billing_group_id) REFERENCES billing_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
2/18/2015
Changes to invoice
ALTER TABLE invoice
ADD COLUMN matter_id uuid;
ALTER TABLE invoice
ADD CONSTRAINT "FK_invoice_matter_MatterId" FOREIGN KEY (matter_id) REFERENCES matter (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
Table changes to invoice_time
ALTER TABLE invoice_time
DROP COLUMN price_per_unit;
ALTER TABLE invoice_time
DROP COLUMN quantity;
ALTER TABLE invoice_time
ADD COLUMN duration interval NOT NULL;
ALTER TABLE invoice_time
ADD COLUMN price_per_hour money NOT NULL;
2/16/2015
Add columns to invoice
ALTER TABLE invoice
ADD COLUMN bill_to_name_line_1 text NOT NULL;
ALTER TABLE invoice
ADD COLUMN bill_to_name_line_2 text;
ALTER TABLE invoice
ADD COLUMN bill_to_address_line_1 text NOT NULL;
ALTER TABLE invoice
ADD COLUMN bill_to_address_line_2 text;
ALTER TABLE invoice
ADD COLUMN bill_to_city text NOT NULL;
ALTER TABLE invoice
ADD COLUMN bill_to_state text NOT NULL;
ALTER TABLE invoice
ADD COLUMN bill_to_zip text NOT NULL;
2/15/2015
Add columns to matter
ALTER TABLE matter
ADD COLUMN default_billing_rate_id integer;
ALTER TABLE matter
ADD COLUMN billing_group_id integer;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_billing_rate_DefaultBillingRateId_Id" FOREIGN KEY (default_billing_rate_id) REFERENCES billing_rate (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE matter
ADD CONSTRAINT "FK_matter_billing_group_BillingGroupId_Id" FOREIGN KEY (billing_group_id) REFERENCES billing_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
Add billing_group table
-- Table: billing_group
-- DROP TABLE billing_group;
CREATE TABLE billing_group
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
last_run timestamp without time zone,
next_run timestamp without time zone NOT NULL,
amount money NOT NULL,
bill_to_contact_id integer NOT NULL,
CONSTRAINT billing_group_pkey PRIMARY KEY (id),
CONSTRAINT "FK_billing_group_contact_BillToContactId_Id" FOREIGN KEY (bill_to_contact_id)
REFERENCES contact (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE billing_group
OWNER TO postgres;
2/8/2015
ALTER TABLE invoice
ADD COLUMN external_invoice_id text;
1/29/2015
-- Table: expense
-- DROP TABLE expense;
CREATE TABLE expense
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
incurred timestamp without time zone NOT NULL,
paid timestamp without time zone,
vendor text NOT NULL,
amount money NOT NULL,
details text NOT NULL,
CONSTRAINT expense_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE expense
OWNER TO postgres;
-- Table: expense_matter
-- DROP TABLE expense_matter;
CREATE TABLE expense_matter
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
matter_id uuid NOT NULL,
expense_id uuid NOT NULL,
CONSTRAINT expense_matter_pkey PRIMARY KEY (id),
CONSTRAINT "FK_expense_matter_ExpenseId" FOREIGN KEY (expense_id)
REFERENCES expense (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_expense_matter_MatterId" FOREIGN KEY (matter_id)
REFERENCES matter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE expense_matter
OWNER TO postgres;
-- Table: fee
-- DROP TABLE fee;
CREATE TABLE fee
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
incurred timestamp without time zone NOT NULL,
amount money NOT NULL,
details text NOT NULL,
CONSTRAINT fee_pkey PRIMARY KEY (id)
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE fee
OWNER TO postgres;
-- Table: fee_matter
-- DROP TABLE fee_matter;
CREATE TABLE fee_matter
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
matter_id uuid NOT NULL,
fee_id uuid NOT NULL,
CONSTRAINT fee_matter_pkey PRIMARY KEY (id),
CONSTRAINT "fee_matter_FeeId" FOREIGN KEY (fee_id)
REFERENCES fee (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fee_matter_MatterId" FOREIGN KEY (matter_id)
REFERENCES matter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE fee_matter
OWNER TO postgres;
-- Table: invoice
-- DROP TABLE invoice;
CREATE TABLE invoice
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
bill_to_contact_id integer NOT NULL,
date timestamp without time zone NOT NULL,
due timestamp without time zone NOT NULL,
subtotal money NOT NULL,
tax_amount money NOT NULL,
total money NOT NULL,
CONSTRAINT invoice_pkey PRIMARY KEY (id),
CONSTRAINT "invoice_contact_BillToContactId" FOREIGN KEY (bill_to_contact_id)
REFERENCES contact (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE invoice
OWNER TO postgres;
-- Table: invoice_expense
-- DROP TABLE invoice_expense;
CREATE TABLE invoice_expense
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
invoice_id uuid NOT NULL,
expense_id uuid NOT NULL,
amount money NOT NULL,
details text NOT NULL,
CONSTRAINT invoice_expense_pkey PRIMARY KEY (id),
CONSTRAINT "invoice_expense_expense_ExpenseId" FOREIGN KEY (expense_id)
REFERENCES expense (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "invoice_expense_invoice_InvoiceId" FOREIGN KEY (invoice_id)
REFERENCES invoice (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE invoice_expense
OWNER TO postgres;
-- Table: invoice_fee
-- DROP TABLE invoice_fee;
CREATE TABLE invoice_fee
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
invoice_id uuid NOT NULL,
fee_id uuid NOT NULL,
amount money NOT NULL,
tax_amount money NOT NULL,
details text NOT NULL,
CONSTRAINT invoice_fee_pkey PRIMARY KEY (id),
CONSTRAINT "invoice_fee_fee_FeeId" FOREIGN KEY (fee_id)
REFERENCES fee (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "invoice_fee_invoice_InvoiceId" FOREIGN KEY (invoice_id)
REFERENCES invoice (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE invoice_fee
OWNER TO postgres;
-- Table: invoice_time
-- DROP TABLE invoice_time;
CREATE TABLE invoice_time
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id uuid NOT NULL,
invoice_id uuid NOT NULL,
time_id uuid NOT NULL,
price_per_unit money NOT NULL,
quantity numeric(10,4) NOT NULL DEFAULT 1,
details text NOT NULL,
CONSTRAINT invoice_time_pkey PRIMARY KEY (id),
CONSTRAINT "invoice_time_invoice_InvoiceId" FOREIGN KEY (invoice_id)
REFERENCES invoice (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "invoice_time_time_TimeId" FOREIGN KEY (time_id)
REFERENCES "time" (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
INHERITS (core)
WITH (
OIDS=FALSE
);
ALTER TABLE invoice_time
OWNER TO postgres;
-------------------------------------------------------------------------------------
1/27/2015
To add columns to matter
ALTER TABLE matter
ADD COLUMN minimum_charge money;
ALTER TABLE matter
ADD COLUMN estimated_charge money;
ALTER TABLE matter
ADD COLUMN maximum_charge money;
1/25/2015
To create the billing_rate table
-- Table: billing_rate
-- DROP TABLE billing_rate;
CREATE TABLE billing_rate
(
-- Inherited from table core: created_by_user_pid uuid NOT NULL,
-- Inherited from table core: modified_by_user_pid uuid NOT NULL,
-- Inherited from table core: disabled_by_user_pid uuid,
-- Inherited from table core: utc_created timestamp without time zone NOT NULL,
-- Inherited from table core: utc_modified timestamp without time zone NOT NULL,
-- Inherited from table core: utc_disabled timestamp without time zone,
id serial NOT NULL,
title text NOT NULL,
price_per_unit money NOT NULL,
CONSTRAINT billing_rates_pkey PRIMARY KEY (id),
CONSTRAINT billing_rates_title_unique UNIQUE (title)
)
INHERITS (core)