| author | Tomas Zeman <tzeman@volny.cz> |
| Fri, 27 Apr 2012 12:04:35 +0200 | |
| changeset 81 | c7d21399c726 |
| parent 79 | 25392159b6ca |
| child 83 | f7553032b302 |
| permissions | -rw-r--r-- |
| 36 | 1 |
-- table declarations : |
2 |
create table "code_list_item" ( |
|
3 |
"l3" bigint not null, |
|
4 |
"l1" bigint not null, |
|
5 |
"i18n" boolean not null, |
|
6 |
"name" varchar(100) not null, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
7 |
"updated_at" timestamp not null, |
| 36 | 8 |
"ol2" bigint, |
9 |
"s3" varchar(200) not null, |
|
10 |
"id" bigint primary key not null, |
|
11 |
"oi1" integer, |
|
12 |
"rank" integer not null, |
|
13 |
"code_list" varchar(40) not null, |
|
14 |
"dflt" boolean not null, |
|
15 |
"s2" varchar(200) not null, |
|
16 |
"i3" integer not null, |
|
17 |
"os1" varchar(200), |
|
18 |
"ol1" bigint, |
|
19 |
"oi2" integer, |
|
20 |
"i1" integer not null, |
|
21 |
"s1" varchar(200) not null, |
|
22 |
"note" varchar(10240), |
|
23 |
"os2" varchar(200), |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
24 |
"created_at" timestamp not null, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
25 |
"created_by" bigint, |
| 36 | 26 |
"i2" integer not null, |
27 |
"oi3" integer, |
|
28 |
"l2" bigint not null, |
|
29 |
"ol3" bigint, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
30 |
"updated_by" bigint, |
| 36 | 31 |
"os3" varchar(200), |
32 |
"deleted" boolean not null |
|
33 |
); |
|
34 |
create sequence "code_list_item_id_seq"; |
|
35 |
-- indexes on code_list_item |
|
36 |
create index "code_list_item_code_list_idx" on "code_list_item" ("code_list");
|
|
37 |
create table "city" ( |
|
38 |
"name" varchar(100) not null, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
39 |
"updated_at" timestamp not null, |
| 36 | 40 |
"id" bigint primary key not null, |
41 |
"country_id" bigint not null, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
42 |
"note" varchar(10240), |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
43 |
"created_at" timestamp not null, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
44 |
"created_by" bigint, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
45 |
"updated_by" bigint |
| 36 | 46 |
); |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
47 |
create sequence "city_id_seq"; |
| 36 | 48 |
create table "address" ( |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
49 |
"city_id" bigint not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
50 |
"name" varchar(100) not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
51 |
"updated_at" timestamp not null, |
| 36 | 52 |
"id" bigint primary key not null, |
53 |
"zip_code" varchar(100) not null, |
|
54 |
"street_name" varchar(100) not null, |
|
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
55 |
"note" varchar(10240), |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
56 |
"created_at" timestamp not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
57 |
"created_by" bigint, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
58 |
"street_num" varchar(100) not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
59 |
"updated_by" bigint |
| 36 | 60 |
); |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
61 |
create sequence "address_id_seq"; |
| 36 | 62 |
create table "country" ( |
63 |
"iso3" varchar(3) not null, |
|
64 |
"name" varchar(100) not null, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
65 |
"updated_at" timestamp not null, |
| 36 | 66 |
"id" bigint primary key not null, |
67 |
"iso2" varchar(2) not null, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
68 |
"note" varchar(10240), |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
69 |
"created_at" timestamp not null, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
70 |
"created_by" bigint, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
71 |
"updated_by" bigint |
| 36 | 72 |
); |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
73 |
create sequence "country_id_seq"; |
| 76 | 74 |
create table "location" ( |
75 |
"name" varchar(100) not null, |
|
76 |
"updated_at" timestamp not null, |
|
77 |
"id" bigint primary key not null, |
|
78 |
"latitude" double precision not null, |
|
79 |
"longitude" double precision not null, |
|
80 |
"note" varchar(10240), |
|
81 |
"created_at" timestamp not null, |
|
82 |
"created_by" bigint, |
|
83 |
"address_id" bigint not null, |
|
84 |
"updated_by" bigint |
|
85 |
); |
|
86 |
create sequence "location_id_seq"; |
|
| 36 | 87 |
create table "contact" ( |
88 |
"name" varchar(100) not null, |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
89 |
"updated_at" timestamp not null, |
| 36 | 90 |
"id" bigint primary key not null, |
91 |
"work_mobile" varchar(40) not null, |
|
92 |
"private_mail" varchar(256), |
|
93 |
"last_name" varchar(80) not null, |
|
94 |
"work_mail" varchar(256) not null, |
|
95 |
"first_name" varchar(80) not null, |
|
96 |
"fax" varchar(40), |
|
97 |
"note" varchar(10240), |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
98 |
"created_at" timestamp not null, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
99 |
"created_by" bigint, |
| 36 | 100 |
"other_mail" varchar(256), |
101 |
"position" varchar(40), |
|
102 |
"other_mobile" varchar(40), |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
103 |
"updated_by" bigint, |
| 36 | 104 |
"private_mobile" varchar(40), |
105 |
"private_phone" varchar(40), |
|
106 |
"work_phone" varchar(40) |
|
107 |
); |
|
108 |
create sequence "contact_id_seq"; |
|
109 |
create table "company" ( |
|
110 |
"name" varchar(100) not null, |
|
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
111 |
"dic" varchar(40) not null, |
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
112 |
"updated_at" timestamp not null, |
| 36 | 113 |
"id" bigint primary key not null, |
114 |
"ico" varchar(40) not null, |
|
115 |
"note" varchar(10240), |
|
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
116 |
"created_at" timestamp not null, |
|
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
117 |
"created_by" bigint, |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
118 |
"address_id" bigint not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
119 |
"post_adress_id" bigint, |
|
61
b65843860274
Trackable entity: created/updated fields
Tomas Zeman <tzeman@volny.cz>
parents:
56
diff
changeset
|
120 |
"updated_by" bigint, |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
121 |
"pin" integer not null |
| 36 | 122 |
); |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
123 |
create sequence "company_id_seq"; |
| 36 | 124 |
create table "bank_account" ( |
125 |
"number" bigint not null, |
|
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
126 |
"name" varchar(100) not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
127 |
"updated_at" timestamp not null, |
| 36 | 128 |
"id" bigint primary key not null, |
129 |
"prefix" bigint not null, |
|
130 |
"bank_code" varchar(100) not null, |
|
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
131 |
"company_id" bigint not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
132 |
"note" varchar(10240), |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
133 |
"created_at" timestamp not null, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
134 |
"created_by" bigint, |
|
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
135 |
"updated_by" bigint |
| 36 | 136 |
); |
|
65
a35a0edf9ddd
Geo+Company record refactoring
Tomas Zeman <tzeman@volny.cz>
parents:
61
diff
changeset
|
137 |
create sequence "bank_account_id_seq"; |
| 72 | 138 |
create table "company_contact" ( |
139 |
"contact" bigint not null, |
|
140 |
"entity" bigint not null |
|
141 |
); |
|
| 73 | 142 |
create table "user" ( |
143 |
"name" varchar(100) not null, |
|
144 |
"updated_at" timestamp not null, |
|
145 |
"id" bigint primary key not null, |
|
146 |
"note" varchar(10240), |
|
147 |
"created_at" timestamp not null, |
|
148 |
"created_by" bigint, |
|
149 |
"login" varchar(40) not null, |
|
150 |
"updated_by" bigint, |
|
151 |
"deleted" boolean not null, |
|
152 |
"active" boolean not null, |
|
153 |
"password" varchar(128) not null |
|
154 |
); |
|
155 |
create sequence "user_id_seq"; |
|
156 |
-- indexes on user |
|
157 |
create index "user_login_idx" on "user" ("login");
|
|
158 |
create table "user_contact" ( |
|
159 |
"contact" bigint not null, |
|
160 |
"entity" bigint not null |
|
161 |
); |
|
| 79 | 162 |
create table "project" ( |
163 |
"name" varchar(100) not null, |
|
164 |
"updated_at" timestamp not null, |
|
165 |
"id" bigint primary key not null, |
|
166 |
"description" varchar(40960) not null, |
|
167 |
"responsible" bigint not null, |
|
168 |
"deadline" timestamp not null, |
|
169 |
"ident_s" varchar(256) not null, |
|
170 |
"state" bigint not null, |
|
171 |
"note" varchar(10240), |
|
172 |
"product_line" bigint, |
|
173 |
"created_at" timestamp not null, |
|
174 |
"created_by" bigint, |
|
175 |
"updated_by" bigint |
|
176 |
); |
|
177 |
create sequence "project_id_seq"; |
|
| 81 | 178 |
create table "task" ( |
179 |
"name" varchar(100) not null, |
|
180 |
"updated_at" timestamp not null, |
|
181 |
"id" bigint primary key not null, |
|
182 |
"project_id" bigint not null, |
|
183 |
"responsible" bigint not null, |
|
184 |
"deadline" timestamp not null, |
|
185 |
"state" bigint not null, |
|
186 |
"note" varchar(10240), |
|
187 |
"created_at" timestamp not null, |
|
188 |
"created_by" bigint, |
|
189 |
"task_type" bigint, |
|
190 |
"updated_by" bigint |
|
191 |
); |
|
192 |
create sequence "task_id_seq"; |
|
| 36 | 193 |
-- foreign key constraints : |
194 |
alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id");
|
|
195 |
alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id");
|
|
| 76 | 196 |
alter table "location" add constraint "locationFK3" foreign key ("address_id") references "address"("id");
|
197 |
alter table "company" add constraint "companyFK4" foreign key ("address_id") references "address"("id");
|
|
198 |
alter table "company" add constraint "companyFK5" foreign key ("post_adress_id") references "address"("id") on delete set null;
|
|
199 |
alter table "bank_account" add constraint "bank_accountFK6" foreign key ("company_id") references "company"("id") on delete cascade;
|
|
| 79 | 200 |
alter table "project" add constraint "projectFK11" foreign key ("responsible") references "user"("id");
|
201 |
alter table "project" add constraint "projectFK12" foreign key ("product_line") references "code_list_item"("id") on delete set null;
|
|
202 |
alter table "project" add constraint "projectFK13" foreign key ("state") references "code_list_item"("id");
|
|
| 81 | 203 |
alter table "task" add constraint "taskFK14" foreign key ("responsible") references "user"("id");
|
204 |
alter table "task" add constraint "taskFK15" foreign key ("task_type") references "code_list_item"("id");
|
|
205 |
alter table "task" add constraint "taskFK16" foreign key ("state") references "code_list_item"("id");
|
|
206 |
alter table "task" add constraint "taskFK17" foreign key ("project_id") references "project"("id");
|
|
| 76 | 207 |
alter table "company_contact" add constraint "company_contactFK7" foreign key ("entity") references "company"("id") on delete cascade;
|
208 |
alter table "company_contact" add constraint "company_contactFK8" foreign key ("contact") references "contact"("id") on delete cascade;
|
|
209 |
alter table "user_contact" add constraint "user_contactFK9" foreign key ("entity") references "user"("id") on delete cascade;
|
|
210 |
alter table "user_contact" add constraint "user_contactFK10" foreign key ("contact") references "contact"("id") on delete cascade;
|
|
| 72 | 211 |
-- composite key indexes : |
212 |
alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact");
|
|
| 73 | 213 |
alter table "user_contact" add constraint "user_contactCPK" unique("entity","contact");
|
| 56 | 214 |
-- column group indexes : |
215 |
create index "user_deleted_active_idx" on "user" ("deleted","active");
|