| author | Tomas Zeman <tzeman@volny.cz> |
| Wed, 30 May 2012 22:51:02 +0200 | |
| changeset 100 | 1fcbeae1f9da |
| parent 99 | 49eb72a46208 |
| child 101 | b6a00fd29998 |
| permissions | -rw-r--r-- |
|
98
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
1 |
-- DATABASE SCHEMA CHANGES BETWEEN 0.2 -> 0.3 VERSION |
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
2 |
|
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
3 |
-- project_location |
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
4 |
create table "project_location" ( |
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
5 |
"location" bigint not null, |
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
6 |
"project" bigint not null |
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
7 |
); |
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
8 |
alter table "project_location" add foreign key ("project") references "project"("id") on delete cascade;
|
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
9 |
alter table "project_location" add foreign key ("location") references "location"("id") on delete cascade;
|
|
eac38214183d
9830b81e1c79d212 Project locations
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
10 |
alter table "project_location" add unique("project","location");
|
| 99 | 11 |
|
12 |
-- service |
|
13 |
create table "service" ( |
|
14 |
"name" varchar(100) not null, |
|
15 |
"updated_at" timestamp not null, |
|
16 |
"id" bigint primary key not null, |
|
17 |
"to" timestamp, |
|
18 |
"state" bigint not null, |
|
19 |
"company" bigint not null, |
|
20 |
"note" varchar(10240), |
|
21 |
"from" timestamp not null, |
|
22 |
"created_at" timestamp not null, |
|
23 |
"created_by" bigint, |
|
24 |
"updated_by" bigint |
|
25 |
); |
|
26 |
create sequence "service_id_seq"; |
|
27 |
alter table "service" add foreign key ("company") references "company"("id");
|
|
28 |
alter table "service" add foreign key ("state") references "code_list_item"("id");
|
|
29 |
||
30 |
-- service payment |
|
31 |
create table "service_payment" ( |
|
32 |
"id" bigint primary key not null, |
|
33 |
"service" bigint not null, |
|
34 |
"direction" integer not null, |
|
35 |
"period" bigint not null, |
|
36 |
"amount" numeric(16,2) not null, |
|
37 |
"currency" bigint not null |
|
38 |
); |
|
39 |
create sequence "service_payment_id_seq"; |
|
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");
|
|
42 |
alter table "service_payment" add foreign key ("currency") references "code_list_item"("id");
|
|
43 |
||
| 100 | 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");
|