-- v28 Default Zone auto-code and map-point readiness
-- Safe/idempotent helper migration. Existing uq_default_zone_code index is already short enough, so no destructive index change is required.

ALTER TABLE default_zones
  MODIFY zone_code VARCHAR(60) NOT NULL;

UPDATE default_zones
SET zone_code = CONCAT('DZ', LPAD(id, 5, '0'))
WHERE (zone_code IS NULL OR zone_code = '') AND id IS NOT NULL;

CREATE INDEX ix_dz_status_v28 ON default_zones (status, is_delete);
CREATE INDEX ix_dz_city_v28 ON default_zones (city, is_delete);
