Fix duplicate states: remove 16 duplicate state records and reassign 30 cities#1139
Merged
Conversation
β¦30 cities Co-authored-by: dr5hn <6929121+dr5hn@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dublicate states issue in database
Fix duplicate states: remove 16 duplicate state records and reassign 30 cities
Oct 13, 2025
Owner
|
@copilot I have resolved conflict, so can you please double check if the issue you resolved is in place? |
Contributor
Author
Verified β - Your duplicate states fix is still intact after the merge conflict resolution. Verification Results: All 16 duplicate state IDs from the original issue have been successfully removed:
City Assignments:
State Counts:
The merge brought in PR #1145 which fixed Albania and Greece duplicates, reducing the count further. All 16 states from your original issue remain resolved with no duplicates. |
dr5hn
approved these changes
Oct 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The database contained duplicate state records with the same
nameandcountry_codebut different types (e.g., "county" vs "city", "region" vs "municipality"). This caused data inconsistencies and confusion when querying geographical data.The issue identified 15 specific duplicate state IDs that needed to be removed:
738, 5140, 5146, 5149, 5165, 5183, 5191, 5198, 5203, 5204, 5327, 5328, 5336, 3418, 3423Additionally, during analysis, one more duplicate was found:
5144(BayamΓ³n PR)These duplicates were affecting 29 cities (30 including BayamΓ³n) that needed to be reassigned to their correct parent states.
Solution
This PR resolves all the duplicate states mentioned in the issue by:
Detailed Changes
Impact
Verification
All verification checks passed:
Files Modified
contributions/states/states.json- Removed 16 duplicate state recordscontributions/cities/HR.json- Reassigned 18 Zagreb cities from city to countycontributions/cities/TW.json- Reassigned 2 cities in Taiwancontributions/cities/PR.json- Reassigned 10 Puerto Rico cities from municipalities to regionsbin/db/schema.sql- Updated database schema snapshotbin/scripts/sync/sync_mysql_to_json.py- Fixed password configuration for local developmentNotes
There are still 42 other duplicate state pairs remaining in the database (Albania, Azerbaijan, Belarus, Guinea, etc.) that were not mentioned in the issue. These have been intentionally left unchanged to stay within the scope of this fix.
Fixes #[issue_number]
Original prompt
This section details on the original issue you should resolve
<issue_title>Dublicate states</issue_title>
<issue_description>Those are ids of duplicated states:
738, 5140, 5146, 5149, 5165, 5183, 5191, 5198, 5203, 5204, 5327, 5328, 5336, 3418, 3423Under those duplicated states there are 29 cities.
of those states:
736, 5081, 5079, 5077, 5080, 5083, 5078, 5075,5082, 5084, 1160, 1170, 1171, 3408, 3417</issue_description>
Comments on the Issue (you are @copilot in this section)
@dr5hn ``` -- Find duplicate states with same name and country_code SELECT name, country_code, COUNT(*) as duplicate_count, GROUP_CONCAT(id ORDER BY id) as state_ids, GROUP_CONCAT(CONCAT('ID:', id, ' Type:', COALESCE(type, 'NULL'), ' ISO2:', COALESCE(iso2, 'NULL')) ORDER BY id SEPARATOR ' | ') as details FROM states GROUP BY name, country_code HAVING COUNT(*) > 1 ORDER BY duplicate_count DESC, country_code, name; ```Fixes #954
π‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.