17 lines
582 B
SQL
17 lines
582 B
SQL
-- Add country_code to existing prc_zone (skip if re-running full zone_country.sql)
|
|
-- charset: utf8mb4
|
|
|
|
ALTER TABLE prc_zone
|
|
ADD COLUMN country_code VARCHAR(10) NULL COMMENT 'ISO2 country code from bms_region' AFTER region_id;
|
|
|
|
UPDATE prc_zone z
|
|
INNER JOIN bms_region r ON r.region_id = z.region_id
|
|
SET z.country_code = r.country_code_2
|
|
WHERE z.country_code IS NULL OR z.country_code = '';
|
|
|
|
ALTER TABLE prc_zone
|
|
MODIFY COLUMN country_code VARCHAR(10) NOT NULL COMMENT 'ISO2 country code from bms_region';
|
|
|
|
ALTER TABLE prc_zone
|
|
ADD INDEX idx_zone_country_code (country_code);
|