CREATE TABLE master_app_production.stock_locations (
  id INT(11) AUTO_INCREMENT PRIMARY KEY,
  own_warehouse_id INT(11) COMMENT "倉庫",
  disp_name VARCHAR(40) COMMENT "ロケーション名",
  disp_sort INT(11) COMMENT "優先順位",
  j_name VARCHAR(60) COMMENT "日本語名",
  e_name VARCHAR(40) COMMENT "英語名",
  note VARCHAR(200) COMMENT "備考",
  stock_target_flag_code SMALLINT(6) COMMENT "ターゲット",
  invalid_flag_code SMALLINT(6) COMMENT "有効フラグ",
  deleted_at DATETIME COMMENT "作成日時",
  created_at DATETIME COMMENT "作成日時",
  updated_at DATETIME COMMENT "更新日時"
) ENGINE=InnoDB;

INSERT into menus set menu_category_id=6, name="stock_locations", disp_name="ロケーション", disp_sort=5010, invalid_flag_code=0, created_at=NOW(), updated_at=NOW();

alter table stocks add location_number varchar(255) after serial_number;
alter table shipping_details add location_number varchar(255) after serial_number;
alter table restoration_details add location_number varchar(255) after serial_number;
alter table purchase_details add location_number varchar(255) after serial_number;
alter table adjustment_details add location_number varchar(255) after serial_number;
alter table disposal_details add location_number varchar(255) after serial_number;
alter table order_details add location_number varchar(255) after serial_number;

alter table manufacture_details add location_number varchar(255) after serial_number;
alter table manufacture_product_details add location_number varchar(255) after serial_number;
alter table manufacture_product_details add parent_location_number varchar(255) after parent_serial_number;

update stocks set location_number='';
update shipping_details set location_number='';
update restoration_details set location_number='';
update purchase_details set location_number='';
update adjustment_details set location_number='';
update manufacture_details set location_number='';
update manufacture_product_details set location_number='';
update manufacture_product_details set parent_location_number='';
update disposal_details set location_number='';
update order_details set location_number='';


#ついでにsupplierテーブルのsender_codeの名前を修正
alter table master_app_production.suppliers change sender_code sender_number varchar(255);

#取引入力の明細gridの状態をクリアしないと、ロケーション列が常に出てきてしまう。
delete from http_states where name like "%detail_inner%";
