CREATE TABLE suppliers_users (
  id INT(11) AUTO_INCREMENT PRIMARY KEY,
  user_id INT(11) COMMENT "ユーザー",
  supplier_id INT(11) COMMENT "仕入先",
  note VARCHAR(200) COMMENT "備考",
  created_at DATETIME COMMENT "作成日時",
  updated_at DATETIME COMMENT "更新日時"
) type=InnoDB;

CREATE INDEX supplier_id ON suppliers_users (supplier_id);
CREATE INDEX user_id ON suppliers_users (user_id);

CREATE TABLE customers_users (
  id INT(11) AUTO_INCREMENT PRIMARY KEY,
  user_id INT(11) COMMENT "ユーザー",
  customer_id INT(11) COMMENT "得意先",
  note VARCHAR(200) COMMENT "備考",
  created_at DATETIME COMMENT "作成日時",
  updated_at DATETIME COMMENT "更新日時"
) type=InnoDB;

CREATE INDEX customer_id ON customers_users (customer_id);
CREATE INDEX user_id ON customers_users (user_id);


insert into master_app_production.code_types set id=62, disp_name="ユーザー属性", j_name="ユーザー属性", e_name="user property", invalid_flag_code=0, created_at=NOW(), updated_at=NOW();
insert into master_app_production.code_masters set code_type_id=62, code_number=1,disp_name="社内", disp_sort=1, j_name="社内", e_name="inner", invalid_flag_code=0, created_at=NOW(), updated_at=NOW();
insert into master_app_production.code_masters set code_type_id=62, code_number=2,disp_name="社外", disp_sort=2, j_name="社外", e_name="outer", invalid_flag_code=0, created_at=NOW(), updated_at=NOW();

alter table master_app_production.users add user_type_code SMALLINT(6) COMMENT "ユーザー属性" after session_id ;

update master_app_production.users set user_type_code=1;