69 "created_at" timestamp not null, |
69 "created_at" timestamp not null, |
70 "created_by" bigint, |
70 "created_by" bigint, |
71 "updated_by" bigint |
71 "updated_by" bigint |
72 ); |
72 ); |
73 create sequence "country_id_seq"; |
73 create sequence "country_id_seq"; |
|
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"; |
74 create table "contact" ( |
87 create table "contact" ( |
75 "name" varchar(100) not null, |
88 "name" varchar(100) not null, |
76 "updated_at" timestamp not null, |
89 "updated_at" timestamp not null, |
77 "id" bigint primary key not null, |
90 "id" bigint primary key not null, |
78 "work_mobile" varchar(40) not null, |
91 "work_mobile" varchar(40) not null, |
147 "entity" bigint not null |
160 "entity" bigint not null |
148 ); |
161 ); |
149 -- foreign key constraints : |
162 -- foreign key constraints : |
150 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); |
163 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); |
151 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); |
164 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); |
152 alter table "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id"); |
165 alter table "location" add constraint "locationFK3" foreign key ("address_id") references "address"("id"); |
153 alter table "company" add constraint "companyFK4" foreign key ("post_adress_id") references "address"("id") on delete set null; |
166 alter table "company" add constraint "companyFK4" foreign key ("address_id") references "address"("id"); |
154 alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id") on delete cascade; |
167 alter table "company" add constraint "companyFK5" foreign key ("post_adress_id") references "address"("id") on delete set null; |
155 alter table "company_contact" add constraint "company_contactFK6" foreign key ("entity") references "company"("id") on delete cascade; |
168 alter table "bank_account" add constraint "bank_accountFK6" foreign key ("company_id") references "company"("id") on delete cascade; |
156 alter table "company_contact" add constraint "company_contactFK7" foreign key ("contact") references "contact"("id") on delete cascade; |
169 alter table "company_contact" add constraint "company_contactFK7" foreign key ("entity") references "company"("id") on delete cascade; |
157 alter table "user_contact" add constraint "user_contactFK8" foreign key ("entity") references "user"("id") on delete cascade; |
170 alter table "company_contact" add constraint "company_contactFK8" foreign key ("contact") references "contact"("id") on delete cascade; |
158 alter table "user_contact" add constraint "user_contactFK9" foreign key ("contact") references "contact"("id") on delete cascade; |
171 alter table "user_contact" add constraint "user_contactFK9" foreign key ("entity") references "user"("id") on delete cascade; |
|
172 alter table "user_contact" add constraint "user_contactFK10" foreign key ("contact") references "contact"("id") on delete cascade; |
159 -- composite key indexes : |
173 -- composite key indexes : |
160 alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact"); |
174 alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact"); |
161 alter table "user_contact" add constraint "user_contactCPK" unique("entity","contact"); |
175 alter table "user_contact" add constraint "user_contactCPK" unique("entity","contact"); |
162 -- column group indexes : |
176 -- column group indexes : |
163 create index "user_deleted_active_idx" on "user" ("deleted","active"); |
177 create index "user_deleted_active_idx" on "user" ("deleted","active"); |