-- Normalize index name across environments where Postgres truncated long identifiers.
DO $$
BEGIN
  IF to_regclass('"OfficialNormativeSuggestion_stateCode_municipalityCode_createdA"') IS NOT NULL
     AND to_regclass('"OfficialNormativeSuggestion_stateCode_municipalityCode_crea_idx"') IS NULL THEN
    ALTER INDEX "OfficialNormativeSuggestion_stateCode_municipalityCode_createdA"
      RENAME TO "OfficialNormativeSuggestion_stateCode_municipalityCode_crea_idx";
  END IF;
END $$;
