39 create sequence "service_payment_id_seq"; |
39 create sequence "service_payment_id_seq"; |
40 alter table "service_payment" add foreign key ("service") references "service"("id") on delete cascade; |
40 alter table "service_payment" add foreign key ("service") references "service"("id") on delete cascade; |
41 alter table "service_payment" add foreign key ("period") references "code_list_item"("id"); |
41 alter table "service_payment" add foreign key ("period") references "code_list_item"("id"); |
42 alter table "service_payment" add foreign key ("currency") references "code_list_item"("id"); |
42 alter table "service_payment" add foreign key ("currency") references "code_list_item"("id"); |
43 |
43 |
|
44 -- attachments |
|
45 create table "attachment" ( |
|
46 "name" varchar(100) not null, |
|
47 "updated_at" timestamp not null, |
|
48 "id" bigint primary key not null, |
|
49 "mime_type" varchar(80) not null, |
|
50 "note" varchar(10240), |
|
51 "content_id" varchar(20) not null, |
|
52 "size" bigint not null, |
|
53 "created_at" timestamp not null, |
|
54 "created_by" bigint, |
|
55 "updated_by" bigint |
|
56 ); |
|
57 create sequence "attachment_id_seq"; |
|
58 create table "project_attachment" ( |
|
59 "project" bigint not null, |
|
60 "attachment" bigint not null |
|
61 ); |
|
62 create table "task_attachment" ( |
|
63 "task" bigint not null, |
|
64 "attachment" bigint not null |
|
65 ); |
|
66 alter table "project_attachment" add foreign key ("project") references "project"("id") on delete cascade; |
|
67 alter table "project_attachment" add foreign key ("attachment") references "attachment"("id") on delete cascade; |
|
68 alter table "task_attachment" add foreign key ("task") references "task"("id") on delete cascade; |
|
69 alter table "task_attachment" add foreign key ("attachment") references "attachment"("id") on delete cascade; |
|
70 alter table "project_attachment" add unique("project","attachment"); |
|
71 alter table "task_attachment" add unique("task","attachment"); |