diff -r 2b0fafd71c1d -r 2ba4569f2bd6 db/db-schema.sql --- a/db/db-schema.sql Fri Apr 20 13:47:21 2012 +0200 +++ b/db/db-schema.sql Tue Apr 24 16:41:59 2012 +0200 @@ -71,6 +71,19 @@ "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, @@ -149,13 +162,14 @@ -- 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 "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id"); -alter table "company" add constraint "companyFK4" foreign key ("post_adress_id") references "address"("id") on delete set null; -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; +alter table "location" add constraint "locationFK3" foreign key ("address_id") references "address"("id"); +alter table "company" add constraint "companyFK4" foreign key ("address_id") references "address"("id"); +alter table "company" add constraint "companyFK5" foreign key ("post_adress_id") references "address"("id") on delete set null; +alter table "bank_account" add constraint "bank_accountFK6" foreign key ("company_id") references "company"("id") on delete cascade; +alter table "company_contact" add constraint "company_contactFK7" foreign key ("entity") references "company"("id") on delete cascade; +alter table "company_contact" add constraint "company_contactFK8" foreign key ("contact") references "contact"("id") on delete cascade; +alter table "user_contact" add constraint "user_contactFK9" foreign key ("entity") references "user"("id") on delete cascade; +alter table "user_contact" add constraint "user_contactFK10" 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");