32 "deleted" boolean not null |
32 "deleted" boolean not null |
33 ); |
33 ); |
34 create sequence "code_list_item_id_seq"; |
34 create sequence "code_list_item_id_seq"; |
35 -- indexes on code_list_item |
35 -- indexes on code_list_item |
36 create index "code_list_item_code_list_idx" on "code_list_item" ("code_list"); |
36 create index "code_list_item_code_list_idx" on "code_list_item" ("code_list"); |
37 create table "user" ( |
|
38 "name" varchar(100) not null, |
|
39 "updated_at" timestamp not null, |
|
40 "id" bigint primary key not null, |
|
41 "note" varchar(10240), |
|
42 "created_at" timestamp not null, |
|
43 "created_by" bigint, |
|
44 "login" varchar(40) not null, |
|
45 "updated_by" bigint, |
|
46 "deleted" boolean not null, |
|
47 "active" boolean not null, |
|
48 "password" varchar(128) not null |
|
49 ); |
|
50 create sequence "user_id_seq"; |
|
51 -- indexes on user |
|
52 create index "user_login_idx" on "user" ("login"); |
|
53 create table "city" ( |
37 create table "city" ( |
54 "name" varchar(100) not null, |
38 "name" varchar(100) not null, |
55 "updated_at" timestamp not null, |
39 "updated_at" timestamp not null, |
56 "id" bigint primary key not null, |
40 "id" bigint primary key not null, |
57 "country_id" bigint not null, |
41 "country_id" bigint not null, |
140 create sequence "bank_account_id_seq"; |
124 create sequence "bank_account_id_seq"; |
141 create table "company_contact" ( |
125 create table "company_contact" ( |
142 "contact" bigint not null, |
126 "contact" bigint not null, |
143 "entity" bigint not null |
127 "entity" bigint not null |
144 ); |
128 ); |
|
129 create table "user" ( |
|
130 "name" varchar(100) not null, |
|
131 "updated_at" timestamp not null, |
|
132 "id" bigint primary key not null, |
|
133 "note" varchar(10240), |
|
134 "created_at" timestamp not null, |
|
135 "created_by" bigint, |
|
136 "login" varchar(40) not null, |
|
137 "updated_by" bigint, |
|
138 "deleted" boolean not null, |
|
139 "active" boolean not null, |
|
140 "password" varchar(128) not null |
|
141 ); |
|
142 create sequence "user_id_seq"; |
|
143 -- indexes on user |
|
144 create index "user_login_idx" on "user" ("login"); |
|
145 create table "user_contact" ( |
|
146 "contact" bigint not null, |
|
147 "entity" bigint not null |
|
148 ); |
145 -- foreign key constraints : |
149 -- foreign key constraints : |
146 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); |
150 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); |
147 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); |
151 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); |
148 alter table "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id"); |
152 alter table "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id"); |
149 alter table "company" add constraint "companyFK4" foreign key ("post_adress_id") references "address"("id") on delete set null; |
153 alter table "company" add constraint "companyFK4" foreign key ("post_adress_id") references "address"("id") on delete set null; |
150 alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id") on delete cascade; |
154 alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id") on delete cascade; |
151 alter table "company_contact" add constraint "company_contactFK6" foreign key ("entity") references "company"("id") on delete cascade; |
155 alter table "company_contact" add constraint "company_contactFK6" foreign key ("entity") references "company"("id") on delete cascade; |
152 alter table "company_contact" add constraint "company_contactFK7" foreign key ("contact") references "contact"("id") on delete cascade; |
156 alter table "company_contact" add constraint "company_contactFK7" foreign key ("contact") references "contact"("id") on delete cascade; |
|
157 alter table "user_contact" add constraint "user_contactFK8" foreign key ("entity") references "user"("id") on delete cascade; |
|
158 alter table "user_contact" add constraint "user_contactFK9" foreign key ("contact") references "contact"("id") on delete cascade; |
153 -- composite key indexes : |
159 -- composite key indexes : |
154 alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact"); |
160 alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact"); |
|
161 alter table "user_contact" add constraint "user_contactCPK" unique("entity","contact"); |
155 -- column group indexes : |
162 -- column group indexes : |
156 create index "user_deleted_active_idx" on "user" ("deleted","active"); |
163 create index "user_deleted_active_idx" on "user" ("deleted","active"); |