diff -r 077b875a2a0c -r 4bcb7deedd3f db/db-schema.sql --- a/db/db-schema.sql Fri Apr 20 08:44:36 2012 +0200 +++ b/db/db-schema.sql Fri Apr 20 09:45:51 2012 +0200 @@ -34,22 +34,6 @@ 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 "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 "city" ( "name" varchar(100) not null, "updated_at" timestamp not null, @@ -142,6 +126,26 @@ "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 + ); -- 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"); @@ -150,7 +154,10 @@ alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id") on delete cascade; alter table "company_contact" add constraint "company_contactFK6" foreign key ("entity") references "company"("id") on delete cascade; alter table "company_contact" add constraint "company_contactFK7" foreign key ("contact") references "contact"("id") on delete cascade; +alter table "user_contact" add constraint "user_contactFK8" foreign key ("entity") references "user"("id") on delete cascade; +alter table "user_contact" add constraint "user_contactFK9" foreign key ("contact") references "contact"("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"); -- column group indexes : create index "user_deleted_active_idx" on "user" ("deleted","active");