db/db-schema.sql
changeset 65 a35a0edf9ddd
parent 61 b65843860274
child 69 b1dc0efd1303
equal deleted inserted replaced
64:90a44ee46732 65:a35a0edf9ddd
    58     "note" varchar(10240),
    58     "note" varchar(10240),
    59     "created_at" timestamp not null,
    59     "created_at" timestamp not null,
    60     "created_by" bigint,
    60     "created_by" bigint,
    61     "updated_by" bigint
    61     "updated_by" bigint
    62   );
    62   );
    63 create sequence "s_city_id";
    63 create sequence "city_id_seq";
    64 create table "address" (
    64 create table "address" (
       
    65     "city_id" bigint not null,
       
    66     "name" varchar(100) not null,
       
    67     "updated_at" timestamp not null,
    65     "id" bigint primary key not null,
    68     "id" bigint primary key not null,
    66     "city_id" bigint not null,
       
    67     "zip_code" varchar(100) not null,
    69     "zip_code" varchar(100) not null,
    68     "street_name" varchar(100) not null,
    70     "street_name" varchar(100) not null,
    69     "street_num" varchar(100) not null
    71     "note" varchar(10240),
       
    72     "created_at" timestamp not null,
       
    73     "created_by" bigint,
       
    74     "street_num" varchar(100) not null,
       
    75     "updated_by" bigint
    70   );
    76   );
    71 create sequence "s_address_id";
    77 create sequence "address_id_seq";
    72 create table "country" (
    78 create table "country" (
    73     "iso3" varchar(3) not null,
    79     "iso3" varchar(3) not null,
    74     "name" varchar(100) not null,
    80     "name" varchar(100) not null,
    75     "updated_at" timestamp not null,
    81     "updated_at" timestamp not null,
    76     "id" bigint primary key not null,
    82     "id" bigint primary key not null,
    78     "note" varchar(10240),
    84     "note" varchar(10240),
    79     "created_at" timestamp not null,
    85     "created_at" timestamp not null,
    80     "created_by" bigint,
    86     "created_by" bigint,
    81     "updated_by" bigint
    87     "updated_by" bigint
    82   );
    88   );
    83 create sequence "s_country_id";
    89 create sequence "country_id_seq";
    84 create table "contact" (
    90 create table "contact" (
    85     "name" varchar(100) not null,
    91     "name" varchar(100) not null,
    86     "updated_at" timestamp not null,
    92     "updated_at" timestamp not null,
    87     "id" bigint primary key not null,
    93     "id" bigint primary key not null,
    88     "work_mobile" varchar(40) not null,
    94     "work_mobile" varchar(40) not null,
   103     "work_phone" varchar(40)
   109     "work_phone" varchar(40)
   104   );
   110   );
   105 create sequence "contact_id_seq";
   111 create sequence "contact_id_seq";
   106 create table "company" (
   112 create table "company" (
   107     "name" varchar(100) not null,
   113     "name" varchar(100) not null,
       
   114     "dic" varchar(40) not null,
   108     "updated_at" timestamp not null,
   115     "updated_at" timestamp not null,
   109     "id" bigint primary key not null,
   116     "id" bigint primary key not null,
   110     "partner" integer not null,
       
   111     "ico" varchar(40) not null,
   117     "ico" varchar(40) not null,
   112     "note" varchar(10240),
   118     "note" varchar(10240),
   113     "created_at" timestamp not null,
   119     "created_at" timestamp not null,
   114     "created_by" bigint,
   120     "created_by" bigint,
   115     "corresp_address_id" bigint,
   121     "address_id" bigint not null,
       
   122     "post_adress_id" bigint,
   116     "updated_by" bigint,
   123     "updated_by" bigint,
   117     "pin" integer not null,
   124     "pin" integer not null
   118     "address_id" bigint not null
       
   119   );
   125   );
   120 create sequence "s_company_id";
   126 create sequence "company_id_seq";
   121 create table "bank_account" (
   127 create table "bank_account" (
   122     "number" bigint not null,
   128     "number" bigint not null,
       
   129     "name" varchar(100) not null,
       
   130     "updated_at" timestamp not null,
   123     "id" bigint primary key not null,
   131     "id" bigint primary key not null,
   124     "prefix" bigint not null,
   132     "prefix" bigint not null,
   125     "bank_code" varchar(100) not null,
   133     "bank_code" varchar(100) not null,
   126     "company_id" bigint not null
   134     "company_id" bigint not null,
       
   135     "note" varchar(10240),
       
   136     "created_at" timestamp not null,
       
   137     "created_by" bigint,
       
   138     "updated_by" bigint
   127   );
   139   );
   128 create sequence "s_bank_account_id";
   140 create sequence "bank_account_id_seq";
   129 -- foreign key constraints :
   141 -- foreign key constraints :
   130 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id");
   142 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id");
   131 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id");
   143 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id");
   132 alter table "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id");
   144 alter table "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id");
   133 alter table "company" add constraint "companyFK4" foreign key ("corresp_address_id") references "address"("id");
   145 alter table "company" add constraint "companyFK4" foreign key ("post_adress_id") references "address"("id");
   134 alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id");
   146 alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id") on delete cascade;
   135 -- column group indexes :
   147 -- column group indexes :
   136 create index "user_deleted_active_idx" on "user" ("deleted","active");
   148 create index "user_deleted_active_idx" on "user" ("deleted","active");