db/db-schema.sql
changeset 65 a35a0edf9ddd
parent 61 b65843860274
child 69 b1dc0efd1303
--- a/db/db-schema.sql	Fri Apr 20 08:26:22 2012 +0200
+++ b/db/db-schema.sql	Fri Apr 20 08:26:23 2012 +0200
@@ -60,15 +60,21 @@
     "created_by" bigint,
     "updated_by" bigint
   );
-create sequence "s_city_id";
+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,
-    "city_id" bigint not null,
     "zip_code" varchar(100) not null,
     "street_name" varchar(100) not null,
-    "street_num" 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 "s_address_id";
+create sequence "address_id_seq";
 create table "country" (
     "iso3" varchar(3) not null,
     "name" varchar(100) not null,
@@ -80,7 +86,7 @@
     "created_by" bigint,
     "updated_by" bigint
   );
-create sequence "s_country_id";
+create sequence "country_id_seq";
 create table "contact" (
     "name" varchar(100) not null,
     "updated_at" timestamp not null,
@@ -105,32 +111,38 @@
 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,
-    "partner" integer not null,
     "ico" varchar(40) not null,
     "note" varchar(10240),
     "created_at" timestamp not null,
     "created_by" bigint,
-    "corresp_address_id" bigint,
+    "address_id" bigint not null,
+    "post_adress_id" bigint,
     "updated_by" bigint,
-    "pin" integer not null,
-    "address_id" bigint not null
+    "pin" integer not null
   );
-create sequence "s_company_id";
+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
+    "company_id" bigint not null,
+    "note" varchar(10240),
+    "created_at" timestamp not null,
+    "created_by" bigint,
+    "updated_by" bigint
   );
-create sequence "s_bank_account_id";
+create sequence "bank_account_id_seq";
 -- 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 ("corresp_address_id") references "address"("id");
-alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id");
+alter table "company" add constraint "companyFK4" foreign key ("post_adress_id") references "address"("id");
+alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id") on delete cascade;
 -- column group indexes :
 create index "user_deleted_active_idx" on "user" ("deleted","active");