-- +goose Up
ALTER TABLE lands
  ADD UNIQUE KEY uq_lands_land_iso_code (land_iso_code);

-- +goose Down
SET @idx_exists := (
  SELECT COUNT(1)
  FROM information_schema.statistics
  WHERE table_schema = DATABASE()
    AND table_name = 'lands'
    AND index_name = 'uq_lands_land_iso_code'
);

SET @drop_sql := IF(
  @idx_exists > 0,
  'ALTER TABLE lands DROP INDEX uq_lands_land_iso_code',
  'SELECT 1'
);

PREPARE stmt FROM @drop_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
