src/main/resources/db/db-schema.sql
changeset 99 49eb72a46208
parent 98 eac38214183d
child 100 1fcbeae1f9da
equal deleted inserted replaced
98:eac38214183d 99:49eb72a46208
   208   );
   208   );
   209 create table "project_location" (
   209 create table "project_location" (
   210     "location" bigint not null,
   210     "location" bigint not null,
   211     "project" bigint not null
   211     "project" bigint not null
   212   );
   212   );
       
   213 create table "service" (
       
   214     "name" varchar(100) not null,
       
   215     "updated_at" timestamp not null,
       
   216     "id" bigint primary key not null,
       
   217     "to" timestamp,
       
   218     "state" bigint not null,
       
   219     "company" bigint not null,
       
   220     "note" varchar(10240),
       
   221     "from" timestamp not null,
       
   222     "created_at" timestamp not null,
       
   223     "created_by" bigint,
       
   224     "updated_by" bigint
       
   225   );
       
   226 create sequence "service_id_seq";
       
   227 create table "service_payment" (
       
   228     "id" bigint primary key not null,
       
   229     "service" bigint not null,
       
   230     "direction" integer not null,
       
   231     "period" bigint not null,
       
   232     "amount" numeric(16,2) not null,
       
   233     "currency" bigint not null
       
   234   );
       
   235 create sequence "service_payment_id_seq";
   213 -- foreign key constraints :
   236 -- foreign key constraints :
   214 alter table "address" add foreign key ("city_id") references "city"("id");
   237 alter table "address" add foreign key ("city_id") references "city"("id");
   215 alter table "city" add foreign key ("country_id") references "country"("id");
   238 alter table "city" add foreign key ("country_id") references "country"("id");
   216 alter table "location" add foreign key ("address_id") references "address"("id");
   239 alter table "location" add foreign key ("address_id") references "address"("id");
   217 alter table "company" add foreign key ("status") references "code_list_item"("id");
   240 alter table "company" add foreign key ("status") references "code_list_item"("id");
   224 alter table "task" add foreign key ("responsible") references "user"("id");
   247 alter table "task" add foreign key ("responsible") references "user"("id");
   225 alter table "task" add foreign key ("task_type") references "code_list_item"("id");
   248 alter table "task" add foreign key ("task_type") references "code_list_item"("id");
   226 alter table "task" add foreign key ("state") references "code_list_item"("id");
   249 alter table "task" add foreign key ("state") references "code_list_item"("id");
   227 alter table "task" add foreign key ("project_id") references "project"("id");
   250 alter table "task" add foreign key ("project_id") references "project"("id");
   228 alter table "comment" add foreign key ("task_id") references "task"("id") on delete cascade;
   251 alter table "comment" add foreign key ("task_id") references "task"("id") on delete cascade;
       
   252 alter table "service" add foreign key ("company") references "company"("id");
       
   253 alter table "service" add foreign key ("state") references "code_list_item"("id");
   229 alter table "company_contact" add foreign key ("entity") references "company"("id") on delete cascade;
   254 alter table "company_contact" add foreign key ("entity") references "company"("id") on delete cascade;
       
   255 alter table "service_payment" add foreign key ("service") references "service"("id") on delete cascade;
       
   256 alter table "service_payment" add foreign key ("period") references "code_list_item"("id");
       
   257 alter table "service_payment" add foreign key ("currency") references "code_list_item"("id");
   230 alter table "company_contact" add foreign key ("contact") references "contact"("id") on delete cascade;
   258 alter table "company_contact" add foreign key ("contact") references "contact"("id") on delete cascade;
   231 alter table "user_contact" add foreign key ("entity") references "user"("id") on delete cascade;
   259 alter table "user_contact" add foreign key ("entity") references "user"("id") on delete cascade;
   232 alter table "user_contact" add foreign key ("contact") references "contact"("id") on delete cascade;
   260 alter table "user_contact" add foreign key ("contact") references "contact"("id") on delete cascade;
   233 alter table "project_company" add foreign key ("project") references "project"("id") on delete cascade;
   261 alter table "project_company" add foreign key ("project") references "project"("id") on delete cascade;
   234 alter table "project_company" add foreign key ("company") references "company"("id") on delete cascade;
   262 alter table "project_company" add foreign key ("company") references "company"("id") on delete cascade;