ALTER TABLE `xxk_proxy_city_library`
  RENAME TO `xxk_proxy_region`;

ALTER TABLE `xxk_proxy_region`
  CHANGE COLUMN `city_code` `region_code` varchar(64) NOT NULL COMMENT '地区编号',
  CHANGE COLUMN `city_name_zh` `region_name_zh` varchar(100) NOT NULL COMMENT '地区中文名',
  CHANGE COLUMN `city_name_en` `region_name` varchar(100) NOT NULL COMMENT '地区名称',
  CHANGE COLUMN `icon_url` `icon_url` varchar(500) NOT NULL COMMENT '地区图标',
  DROP COLUMN `country_code`,
  DROP COLUMN `country_name`;

ALTER TABLE `xxk_product_static_country_price`
  ADD COLUMN `region_id` bigint DEFAULT NULL COMMENT '地区ID' AFTER `product_id`,
  ADD COLUMN `region_code` varchar(64) DEFAULT NULL COMMENT '地区编号' AFTER `region_id`,
  ADD COLUMN `region_name` varchar(100) DEFAULT NULL COMMENT '地区名称' AFTER `region_code`,
  ADD COLUMN `region_name_zh` varchar(100) DEFAULT NULL COMMENT '地区中文名' AFTER `region_name`;

UPDATE `xxk_product_static_country_price`
SET
  `region_code` = `country_code`,
  `region_name` = IFNULL(`region_name`, `country_name`),
  `region_name_zh` = IFNULL(`region_name_zh`, `country_name`)
WHERE `region_code` IS NULL OR `region_name_zh` IS NULL;

ALTER TABLE `xxk_product_static_country_price`
  ADD KEY `idx_static_price_region_id` (`region_id`);
