# HG changeset patch # User Tomas Zeman # Date 1336029768 -7200 # Node ID eb207b18933266acc790ba67290da1e43c1287ea # Parent 494b3b9db4632e16d543e60eb4b7332637edc683 Database schema updates diff -r 494b3b9db463 -r eb207b189332 db/db-data.sql --- a/db/db-data.sql Tue May 01 23:54:09 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ --- Project states -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('project_state', nextval('code_list_item_id_seq'), true, 'project.state.assigned', 10, true, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('project_state', nextval('code_list_item_id_seq'), true, 'project.state.paused', 45, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('project_state', nextval('code_list_item_id_seq'), true, 'project.state.in_preparation', 20, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('project_state', nextval('code_list_item_id_seq'), true, 'project.state.in_realization', 30, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('project_state', nextval('code_list_item_id_seq'), true, 'project.state.cancelled', 50, false, 1, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('project_state', nextval('code_list_item_id_seq'), true, 'project.state.realized', 40, false, 1, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); - --- Task states -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 0, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 10, false, 10, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 20, false, 20, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 30, false, 30, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 40, false, 40, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 50, false, 50, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 60, false, 60, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 70, false, 70, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 80, false, 80, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 90, false, 90, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_state', nextval('code_list_item_id_seq'), false, '', 100, false, 100, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); - --- Task types -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_type', nextval('code_list_item_id_seq'), true, 'Task type 1', 1, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('task_type', nextval('code_list_item_id_seq'), true, 'Task type 2', 2, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); - --- Company status -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('company_status', nextval('code_list_item_id_seq'), true, 'company.status.active', 10, true, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('company_status', nextval('code_list_item_id_seq'), true, 'company.status.potencial', 20, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); -INSERT INTO code_list_item -(code_list, id, i18n, name, rank, dflt, i1, -i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) -VALUES -('company_status', nextval('code_list_item_id_seq'), true, 'company.status.inactive', 30, false, 0, -0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); diff -r 494b3b9db463 -r eb207b189332 db/db-schema.sql --- a/db/db-schema.sql Tue May 01 23:54:09 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,236 +0,0 @@ --- table declarations : -create table "code_list_item" ( - "l3" bigint not null, - "l1" bigint not null, - "i18n" boolean not null, - "name" varchar(100) not null, - "updated_at" timestamp not null, - "ol2" bigint, - "s3" varchar(200) not null, - "id" bigint primary key not null, - "oi1" integer, - "rank" integer not null, - "code_list" varchar(40) not null, - "dflt" boolean not null, - "s2" varchar(200) not null, - "i3" integer not null, - "os1" varchar(200), - "ol1" bigint, - "oi2" integer, - "i1" integer not null, - "s1" varchar(200) not null, - "note" varchar(10240), - "os2" varchar(200), - "created_at" timestamp not null, - "created_by" bigint, - "i2" integer not null, - "oi3" integer, - "l2" bigint not null, - "ol3" bigint, - "updated_by" bigint, - "os3" varchar(200), - "deleted" boolean not null - ); -create sequence "code_list_item_id_seq"; --- indexes on code_list_item -create index "code_list_item_code_list_idx" on "code_list_item" ("code_list"); -create table "city" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "country_id" bigint not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "updated_by" bigint - ); -create sequence "city_id_seq"; -create table "address" ( - "city_id" bigint not null, - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "zip_code" varchar(100) not null, - "street_name" varchar(100) not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "street_num" varchar(100) not null, - "updated_by" bigint - ); -create sequence "address_id_seq"; -create table "country" ( - "iso3" varchar(3) not null, - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "iso2" varchar(2) not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "updated_by" bigint - ); -create sequence "country_id_seq"; -create table "location" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "latitude" double precision not null, - "longitude" double precision not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "address_id" bigint not null, - "updated_by" bigint - ); -create sequence "location_id_seq"; -create table "contact" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "work_mobile" varchar(40) not null, - "private_mail" varchar(256), - "last_name" varchar(80) not null, - "work_mail" varchar(256) not null, - "first_name" varchar(80) not null, - "fax" varchar(40), - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "other_mail" varchar(256), - "position" varchar(40), - "other_mobile" varchar(40), - "updated_by" bigint, - "private_mobile" varchar(40), - "private_phone" varchar(40), - "work_phone" varchar(40) - ); -create sequence "contact_id_seq"; -create table "company" ( - "name" varchar(100) not null, - "dic" varchar(40) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "ico" varchar(40) not null, - "note" varchar(10240), - "status" bigint not null, - "created_at" timestamp not null, - "created_by" bigint, - "address_id" bigint not null, - "post_adress_id" bigint, - "updated_by" bigint, - "pin" integer not null - ); -create sequence "company_id_seq"; -create table "bank_account" ( - "number" bigint not null, - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "prefix" bigint not null, - "bank_code" varchar(100) not null, - "company_id" bigint not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "updated_by" bigint - ); -create sequence "bank_account_id_seq"; -create table "company_contact" ( - "contact" bigint not null, - "entity" bigint not null - ); -create table "user" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "login" varchar(40) not null, - "updated_by" bigint, - "deleted" boolean not null, - "active" boolean not null, - "password" varchar(128) not null - ); -create sequence "user_id_seq"; --- indexes on user -create index "user_login_idx" on "user" ("login"); -create table "user_contact" ( - "contact" bigint not null, - "entity" bigint not null - ); -create table "project" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "description" varchar(40960) not null, - "responsible" bigint not null, - "deadline" timestamp not null, - "ident_s" varchar(256) not null, - "state" bigint not null, - "note" varchar(10240), - "product_line" bigint, - "created_at" timestamp not null, - "created_by" bigint, - "updated_by" bigint - ); -create sequence "project_id_seq"; -create table "task" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "id" bigint primary key not null, - "project_id" bigint not null, - "responsible" bigint not null, - "deadline" timestamp not null, - "state" bigint not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "task_type" bigint, - "updated_by" bigint - ); -create sequence "task_id_seq"; -create table "comment" ( - "name" varchar(100) not null, - "updated_at" timestamp not null, - "task_id" bigint not null, - "id" bigint primary key not null, - "note" varchar(10240), - "created_at" timestamp not null, - "created_by" bigint, - "updated_by" bigint - ); -create sequence "comment_id_seq"; -create table "project_company" ( - "project" bigint not null, - "company" bigint not null - ); --- foreign key constraints : -alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); -alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); -alter table "location" add constraint "locationFK3" foreign key ("address_id") references "address"("id"); -alter table "company" add constraint "companyFK4" foreign key ("status") references "code_list_item"("id"); -alter table "company" add constraint "companyFK5" foreign key ("address_id") references "address"("id"); -alter table "company" add constraint "companyFK6" foreign key ("post_adress_id") references "address"("id") on delete set null; -alter table "bank_account" add constraint "bank_accountFK7" foreign key ("company_id") references "company"("id") on delete cascade; -alter table "project" add constraint "projectFK12" foreign key ("responsible") references "user"("id"); -alter table "project" add constraint "projectFK13" foreign key ("product_line") references "code_list_item"("id") on delete set null; -alter table "project" add constraint "projectFK14" foreign key ("state") references "code_list_item"("id"); -alter table "task" add constraint "taskFK15" foreign key ("responsible") references "user"("id"); -alter table "task" add constraint "taskFK16" foreign key ("task_type") references "code_list_item"("id"); -alter table "task" add constraint "taskFK17" foreign key ("state") references "code_list_item"("id"); -alter table "task" add constraint "taskFK18" foreign key ("project_id") references "project"("id"); -alter table "comment" add constraint "commentFK19" foreign key ("task_id") references "task"("id") on delete cascade; -alter table "company_contact" add constraint "company_contactFK8" foreign key ("entity") references "company"("id") on delete cascade; -alter table "company_contact" add constraint "company_contactFK9" foreign key ("contact") references "contact"("id") on delete cascade; -alter table "user_contact" add constraint "user_contactFK10" foreign key ("entity") references "user"("id") on delete cascade; -alter table "user_contact" add constraint "user_contactFK11" foreign key ("contact") references "contact"("id") on delete cascade; -alter table "project_company" add constraint "project_companyFK20" foreign key ("project") references "project"("id") on delete cascade; -alter table "project_company" add constraint "project_companyFK21" foreign key ("company") references "company"("id") on delete cascade; --- composite key indexes : -alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact"); -alter table "user_contact" add constraint "user_contactCPK" unique("entity","contact"); -alter table "project_company" add constraint "project_companyCPK" unique("project","company"); --- column group indexes : -create index "user_deleted_active_idx" on "user" ("deleted","active"); diff -r 494b3b9db463 -r eb207b189332 src/main/resources/db/db-data.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/db/db-data.sql Thu May 03 09:22:48 2012 +0200 @@ -0,0 +1,139 @@ +-- Project states +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('project_state', nextval('code_list_item_id_seq'), true, 'project.state.assigned', 10, true, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('project_state', nextval('code_list_item_id_seq'), true, 'project.state.paused', 45, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('project_state', nextval('code_list_item_id_seq'), true, 'project.state.in_preparation', 20, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('project_state', nextval('code_list_item_id_seq'), true, 'project.state.in_realization', 30, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('project_state', nextval('code_list_item_id_seq'), true, 'project.state.cancelled', 50, false, 1, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('project_state', nextval('code_list_item_id_seq'), true, 'project.state.realized', 40, false, 1, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); + +-- Task states +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 0, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 10, false, 10, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 20, false, 20, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 30, false, 30, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 40, false, 40, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 50, false, 50, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 60, false, 60, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 70, false, 70, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 80, false, 80, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 90, false, 90, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_state', nextval('code_list_item_id_seq'), false, '', 100, false, 100, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); + +-- Task types +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_type', nextval('code_list_item_id_seq'), true, 'Task type 1', 1, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('task_type', nextval('code_list_item_id_seq'), true, 'Task type 2', 2, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); + +-- Company status +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('company_status', nextval('code_list_item_id_seq'), true, 'company.status.active', 10, true, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('company_status', nextval('code_list_item_id_seq'), true, 'company.status.potencial', 20, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('company_status', nextval('code_list_item_id_seq'), true, 'company.status.inactive', 30, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); diff -r 494b3b9db463 -r eb207b189332 src/main/resources/db/db-schema.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/db/db-schema.sql Thu May 03 09:22:48 2012 +0200 @@ -0,0 +1,236 @@ +-- table declarations : +create table "code_list_item" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "i18n" boolean not null, + "rank" integer not null, + "dflt" boolean not null, + "code_list" varchar(40) not null, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint, + "i1" integer not null, + "i2" integer not null, + "i3" integer not null, + "l1" bigint not null, + "l2" bigint not null, + "l3" bigint not null, + "s1" varchar(200) not null, + "s2" varchar(200) not null, + "s3" varchar(200) not null, + "oi1" integer, + "oi2" integer, + "oi3" integer, + "ol1" bigint, + "ol2" bigint, + "ol3" bigint, + "os1" varchar(200), + "os2" varchar(200), + "os3" varchar(200), + "deleted" boolean not null + ); +create sequence "code_list_item_id_seq"; +-- indexes on code_list_item +create index "code_list_item_code_list_idx" on "code_list_item" ("code_list"); +create table "city" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "note" varchar(10240), + "country_id" bigint not null, + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "city_id_seq"; +create table "address" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "street_name" varchar(100) not null, + "street_num" varchar(100) not null, + "zip_code" varchar(100) not null, + "city_id" bigint not null, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "address_id_seq"; +create table "country" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "iso2" varchar(2) not null, + "iso3" varchar(3) not null, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "country_id_seq"; +create table "location" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "address_id" bigint not null, + "note" varchar(10240), + "latitude" double precision not null, + "longitude" double precision not null, + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "location_id_seq"; +create table "contact" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "first_name" varchar(80) not null, + "last_name" varchar(80) not null, + "position" varchar(40), + "note" varchar(10240), + "work_mail" varchar(256) not null, + "work_phone" varchar(40), + "work_mobile" varchar(40) not null, + "private_mail" varchar(256), + "private_phone" varchar(40), + "private_mobile" varchar(40), + "other_mail" varchar(256), + "other_mobile" varchar(40), + "fax" varchar(40), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "contact_id_seq"; +create table "company" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "dic" varchar(40) not null, + "ico" varchar(40) not null, + "note" varchar(10240), + "status" bigint not null, + "address_id" bigint not null, + "post_adress_id" bigint, + "pin" integer not null, + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "company_id_seq"; +create table "bank_account" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "prefix" bigint not null, + "number" bigint not null, + "bank_code" varchar(100) not null, + "company_id" bigint not null, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "bank_account_id_seq"; +create table "company_contact" ( + "contact" bigint not null, + "entity" bigint not null + ); +create table "user" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "login" varchar(40) not null, + "note" varchar(10240), + "active" boolean not null, + "password" varchar(128) not null, + "deleted" boolean not null, + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "user_id_seq"; +-- indexes on user +create index "user_login_idx" on "user" ("login"); +create table "user_contact" ( + "contact" bigint not null, + "entity" bigint not null + ); +create table "project" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "description" varchar(40960) not null, + "responsible" bigint not null, + "deadline" timestamp not null, + "ident_s" varchar(256) not null, + "state" bigint not null, + "product_line" bigint, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "project_id_seq"; +create table "task" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "project_id" bigint not null, + "responsible" bigint not null, + "deadline" timestamp not null, + "state" bigint not null, + "task_type" bigint, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "task_id_seq"; +create table "comment" ( + "id" bigint primary key not null, + "name" varchar(100) not null, + "task_id" bigint not null, + "note" varchar(10240), + "created_at" timestamp not null, + "created_by" bigint, + "updated_at" timestamp not null, + "updated_by" bigint + ); +create sequence "comment_id_seq"; +create table "project_company" ( + "project" bigint not null, + "company" bigint not null + ); +-- foreign key constraints : +alter table "address" add foreign key ("city_id") references "city"("id"); +alter table "city" add foreign key ("country_id") references "country"("id"); +alter table "location" add foreign key ("address_id") references "address"("id"); +alter table "company" add foreign key ("status") references "code_list_item"("id"); +alter table "company" add foreign key ("address_id") references "address"("id"); +alter table "company" add foreign key ("post_adress_id") references "address"("id") on delete set null; +alter table "bank_account" add foreign key ("company_id") references "company"("id") on delete cascade; +alter table "project" add foreign key ("responsible") references "user"("id"); +alter table "project" add foreign key ("product_line") references "code_list_item"("id") on delete set null; +alter table "project" add foreign key ("state") references "code_list_item"("id"); +alter table "task" add foreign key ("responsible") references "user"("id"); +alter table "task" add foreign key ("task_type") references "code_list_item"("id"); +alter table "task" add foreign key ("state") references "code_list_item"("id"); +alter table "task" add foreign key ("project_id") references "project"("id"); +alter table "comment" add foreign key ("task_id") references "task"("id") on delete cascade; +alter table "company_contact" add foreign key ("entity") references "company"("id") on delete cascade; +alter table "company_contact" add foreign key ("contact") references "contact"("id") on delete cascade; +alter table "user_contact" add foreign key ("entity") references "user"("id") on delete cascade; +alter table "user_contact" add foreign key ("contact") references "contact"("id") on delete cascade; +alter table "project_company" add foreign key ("project") references "project"("id") on delete cascade; +alter table "project_company" add foreign key ("company") references "company"("id") on delete cascade; +-- composite key indexes : +alter table "company_contact" add unique("entity","contact"); +alter table "user_contact" add unique("entity","contact"); +alter table "project_company" add unique("project","company"); +-- column group indexes : +create index "user_deleted_active_idx" on "user" ("deleted","active");