alter table accept_orders add buyer_flag smallint(6);
alter table accept_orders add buyer_email varchar(255);
alter table accept_orders add buyer_disp_name varchar(255);
alter table accept_orders add buyer_kana_name varchar(255);
alter table accept_orders add buyer_tel varchar(255);
alter table accept_orders add buyer_fax varchar(255);
alter table accept_orders add buyer_zip varchar(255);
alter table accept_orders add buyer_address_1 varchar(400);
alter table accept_orders add buyer_address_2 varchar(400);

alter table accept_orders add taker_flag smallint(6);
alter table accept_orders add taker_disp_name varchar(255);
alter table accept_orders add taker_kana_name varchar(255);
alter table accept_orders add taker_tel varchar(255);
alter table accept_orders add taker_fax varchar(255);
alter table accept_orders add taker_zip varchar(255);
alter table accept_orders add taker_address_1 varchar(400);
alter table accept_orders add taker_address_2 varchar(400);

alter table shippings add buyer_flag smallint(6);
alter table shippings add buyer_email varchar(255);
alter table shippings add buyer_disp_name varchar(255);
alter table shippings add buyer_kana_name varchar(255);
alter table shippings add buyer_tel varchar(255);
alter table shippings add buyer_fax varchar(255);
alter table shippings add buyer_zip varchar(255);
alter table shippings add buyer_address_1 varchar(400);
alter table shippings add buyer_address_2 varchar(400);

alter table shippings add taker_flag smallint(6);
alter table shippings add taker_disp_name varchar(255);
alter table shippings add taker_kana_name varchar(255);
alter table shippings add taker_tel varchar(255);
alter table shippings add taker_fax varchar(255);
alter table shippings add taker_zip varchar(255);
alter table shippings add taker_address_1 varchar(400);
alter table shippings add taker_address_2 varchar(400);

alter table sales add buyer_flag smallint(6);
alter table sales add buyer_email varchar(255);
alter table sales add buyer_disp_name varchar(255);
alter table sales add buyer_kana_name varchar(255);
alter table sales add buyer_tel varchar(255);
alter table sales add buyer_fax varchar(255);
alter table sales add buyer_zip varchar(255);
alter table sales add buyer_address_1 varchar(400);
alter table sales add buyer_address_2 varchar(400);

alter table sales add taker_flag smallint(6);
alter table sales add taker_disp_name varchar(255);
alter table sales add taker_kana_name varchar(255);
alter table sales add taker_tel varchar(255);
alter table sales add taker_fax varchar(255);
alter table sales add taker_zip varchar(255);
alter table sales add taker_address_1 varchar(400);
alter table sales add taker_address_2 varchar(400);


CREATE TABLE master_app_production.consumers (
  id                   int(11)                AUTO_INCREMENT PRIMARY KEY,
  disp_sort            int(11)                COMMENT "表示番号",
  disp_name            varchar(255)           COMMENT "顧客名",
  j_name               varchar(255)           COMMENT "顧客名(ja)",
  e_name               varchar(255)           COMMENT "顧客名(en)",
  kana_name            varchar(255)           COMMENT "顧客名(カナ)",
  email                varchar(255)           COMMENT "メール",
  tel                  varchar(255)           COMMENT "電話番号",
  fax                  varchar(255)           COMMENT "FAX番号",
  zip                  varchar(255)           COMMENT "郵便番号",
  address_1            varchar(255)           COMMENT "住所1",
  address_2            varchar(255)           COMMENT "住所2",
  taker_disp_name      varchar(255)           COMMENT "お届け先名前",
  taker_kana_name      varchar(255)           COMMENT "お届け先カナ名",
  taker_tel            varchar(255)           COMMENT "お届け先電話",
  taker_fax            varchar(255)           COMMENT "お届け先FAX",
  taker_zip            varchar(255)           COMMENT "お届け先郵便番号",
  taker_address_1      varchar(255)           COMMENT "お届け先住所1",
  taker_address_2      varchar(255)           COMMENT "お届け先住所2",
  note                 varchar(200)           COMMENT "備考",
  invalid_flag_code    smallint(6)            COMMENT "有効フラグ",
  deleted_at           datetime               COMMENT "削除日時",
  created_at           datetime               COMMENT "作成日時",
  updated_at           datetime               COMMENT "更新日時"
) type=InnoDB;
CREATE INDEX email ON master_app_production.consumers (email);

INSERT INTO menus set menu_category_id=6, name="consumers", disp_name="顧客", disp_sort=5009, invalid_flag_code=0, created_at=NOW(), updated_at=NOW();

#ユーザー得意先紐付け
INSERT into master_app_production.master_helps set table_name='consumers', title='顧客', help='法人ではない顧客を定義します。', created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'email', title='メール', help='顧客のメールアドレスになります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_disp_name', title='お届け先名', help='お届け先の名前になります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_kana_name', title='お届け先名(カナ)', help='お届け先のカナ名になります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_zip', title='お届け先郵便番号', help='お届け先の郵便番号になります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_address_1', title='お届け先住所1', help='お届け先の住所1になります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_address_2', title='お届け先住所2', help='お届け先の住所2になります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_tel', title='お届け先電話番号', help='お届け先の電話番号になります。',created_at=NOW(), updated_at=NOW();
INSERT into master_app_production.master_helps set table_name='consumers', col_name = 'taker_fax', title='お届け先FAX番号', help='お届け先のFAX番号になります。',created_at=NOW(), updated_at=NOW();

