src/main/resources/db/db-schema.sql
changeset 100 1fcbeae1f9da
parent 99 49eb72a46208
child 101 b6a00fd29998
equal deleted inserted replaced
99:49eb72a46208 100:1fcbeae1f9da
   158 create index "user_login_idx" on "user" ("login");
   158 create index "user_login_idx" on "user" ("login");
   159 create table "user_contact" (
   159 create table "user_contact" (
   160     "contact" bigint not null,
   160     "contact" bigint not null,
   161     "entity" bigint not null
   161     "entity" bigint not null
   162   );
   162   );
       
   163 create table "attachment" (
       
   164     "name" varchar(100) not null,
       
   165     "updated_at" timestamp not null,
       
   166     "id" bigint primary key not null,
       
   167     "mime_type" varchar(80) not null,
       
   168     "content_id" varchar(20) not null,
       
   169     "size" bigint not null,
       
   170     "note" varchar(10240),
       
   171     "created_at" timestamp not null,
       
   172     "created_by" bigint,
       
   173     "updated_by" bigint
       
   174   );
       
   175 create sequence "attachment_id_seq";
   163 create table "project" (
   176 create table "project" (
   164     "id" bigint primary key not null,
   177     "id" bigint primary key not null,
   165     "name" varchar(100) not null,
   178     "name" varchar(100) not null,
   166     "description" varchar(40960) not null,
   179     "description" varchar(40960) not null,
   167     "responsible" bigint not null,
   180     "responsible" bigint not null,
   207     "company" bigint not null
   220     "company" bigint not null
   208   );
   221   );
   209 create table "project_location" (
   222 create table "project_location" (
   210     "location" bigint not null,
   223     "location" bigint not null,
   211     "project" bigint not null
   224     "project" bigint not null
       
   225   );
       
   226 create table "project_attachment" (
       
   227     "project" bigint not null,
       
   228     "attachment" bigint not null
       
   229   );
       
   230 create table "task_attachment" (
       
   231     "task" bigint not null,
       
   232     "attachment" bigint not null
   212   );
   233   );
   213 create table "service" (
   234 create table "service" (
   214     "name" varchar(100) not null,
   235     "name" varchar(100) not null,
   215     "updated_at" timestamp not null,
   236     "updated_at" timestamp not null,
   216     "id" bigint primary key not null,
   237     "id" bigint primary key not null,
   260 alter table "user_contact" add foreign key ("contact") references "contact"("id") on delete cascade;
   281 alter table "user_contact" add foreign key ("contact") references "contact"("id") on delete cascade;
   261 alter table "project_company" add foreign key ("project") references "project"("id") on delete cascade;
   282 alter table "project_company" add foreign key ("project") references "project"("id") on delete cascade;
   262 alter table "project_company" add foreign key ("company") references "company"("id") on delete cascade;
   283 alter table "project_company" add foreign key ("company") references "company"("id") on delete cascade;
   263 alter table "project_location" add foreign key ("project") references "project"("id") on delete cascade;
   284 alter table "project_location" add foreign key ("project") references "project"("id") on delete cascade;
   264 alter table "project_location" add foreign key ("location") references "location"("id") on delete cascade;
   285 alter table "project_location" add foreign key ("location") references "location"("id") on delete cascade;
       
   286 alter table "project_attachment" add foreign key ("project") references "project"("id") on delete cascade;
       
   287 alter table "project_attachment" add foreign key ("attachment") references "attachment"("id") on delete cascade;
       
   288 alter table "task_attachment" add foreign key ("task") references "task"("id") on delete cascade;
       
   289 alter table "task_attachment" add foreign key ("attachment") references "attachment"("id") on delete cascade;
   265 -- composite key indexes :
   290 -- composite key indexes :
   266 alter table "company_contact" add unique("entity","contact");
   291 alter table "company_contact" add unique("entity","contact");
   267 alter table "user_contact" add unique("entity","contact");
   292 alter table "user_contact" add unique("entity","contact");
   268 alter table "project_company" add unique("project","company");
   293 alter table "project_company" add unique("project","company");
   269 alter table "project_location" add unique("project","location");
   294 alter table "project_location" add unique("project","location");
       
   295 alter table "project_attachment" add unique("project","attachment");
       
   296 alter table "task_attachment" add unique("task","attachment");
   270 -- column group indexes :
   297 -- column group indexes :
   271 create index "user_deleted_active_idx" on "user" ("deleted","active");
   298 create index "user_deleted_active_idx" on "user" ("deleted","active");