Skip to content

Commit d011d74

Browse files
CopilotAakash315
andauthored
fix: Remove deprecated FATA state, merge cities into Khyber Pakhtunkhwa (ISO 3166-2:PK) (#1284)
* Initial plan * Initial plan for Pakistan administrative divisions fix Co-authored-by: Aakash315 <169593545+Aakash315@users.noreply.github.com> * fix: remove FATA and merge cities into Khyber Pakhtunkhwa - Removed Federally Administered Tribal Areas (FATA, state_id 3173) from states.json - Moved 8 cities from FATA to Khyber Pakhtunkhwa (state_id 3171) - Updated state_code from TA to KP for merged cities - Pakistan now has 7 administrative divisions per ISO 3166-2:PK - Added comprehensive fix documentation Co-authored-by: Aakash315 <169593545+Aakash315@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Aakash315 <169593545+Aakash315@users.noreply.github.com>
1 parent 9057a54 commit d011d74

File tree

4 files changed

+222
-59
lines changed

4 files changed

+222
-59
lines changed
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# Fix Summary: Pakistan - Remove Federally Administered Tribal Areas (FATA)
2+
3+
## Issue Reference
4+
**Original Issue:** [Bug]: Pakistan remove extra administered area
5+
**Issue Link:** GitHub Issue (Remove 1 extra administered area - FATA merged with Khyber Pakhtunkhwa)
6+
7+
## Executive Summary
8+
9+
This PR corrects Pakistan's administrative divisions to align with ISO 3166-2:PK standards by removing the deprecated "Federally Administered Tribal Areas" (FATA) and merging its cities into Khyber Pakhtunkhwa province.
10+
11+
### Historical Context
12+
13+
The Federally Administered Tribal Areas (FATA) was a semi-autonomous tribal region in northwestern Pakistan. In 2018, FATA was officially merged with the Khyber Pakhtunkhwa province through the 25th Constitutional Amendment, eliminating it as a separate administrative division.
14+
15+
---
16+
17+
## Changes Made
18+
19+
### Pakistan 🇵🇰
20+
21+
**Problem:** Database contained 8 administrative divisions including the deprecated FATA (PK-TA), which was merged with Khyber Pakhtunkhwa in 2018.
22+
23+
**Solution:**
24+
1. Removed FATA state record from `contributions/states/states.json`
25+
2. Moved all 8 cities from FATA to Khyber Pakhtunkhwa
26+
3. Updated city records with correct state_id and state_code
27+
28+
**Details:**
29+
30+
**Before:**
31+
- 8 administrative divisions (including deprecated FATA)
32+
- FATA (state_id: 3173, state_code: TA) had 8 cities
33+
- Khyber Pakhtunkhwa (state_id: 3171, state_code: KP) had 49 cities
34+
35+
**After:**
36+
- 7 administrative divisions (per ISO 3166-2:PK)
37+
- FATA removed completely
38+
- Khyber Pakhtunkhwa now has 57 cities (49 + 8 merged)
39+
40+
---
41+
42+
## Current Administrative Structure (ISO 3166-2:PK Compliant)
43+
44+
### 7 Administrative Divisions:
45+
46+
| Code | Name | Type | State ID |
47+
|--------|--------------------------|---------------------------|----------|
48+
| PK-JK | Azad Kashmir | Administered Area | 3172 |
49+
| PK-BA | Balochistan | Province | 3174 |
50+
| PK-GB | Gilgit-Baltistan | Administered Area | 3170 |
51+
| PK-IS | Islamabad | Federal Capital Territory | 3169 |
52+
| PK-KP | Khyber Pakhtunkhwa | Province | 3171 |
53+
| PK-PB | Punjab | Province | 3176 |
54+
| PK-SD | Sindh | Province | 3175 |
55+
56+
---
57+
58+
## Cities Merged from FATA to Khyber Pakhtunkhwa
59+
60+
The following 8 cities were moved from FATA (state_id: 3173) to Khyber Pakhtunkhwa (state_id: 3171):
61+
62+
1. **Alizai** (id: 85336)
63+
- Coordinates: 33.53613°N, 70.34607°E
64+
- Native: علیزئی
65+
- WikiData: Q2475251
66+
67+
2. **Gulishah Kach** (id: 85458)
68+
- Coordinates: 32.67087°N, 70.33917°E
69+
- Native: گلشاہ کیچ
70+
- WikiData: Q243322
71+
72+
3. **Landi Kotal** (id: 85577)
73+
- Coordinates: 34.09880°N, 71.14108°E
74+
- Native: لنڈی کوتل
75+
- WikiData: Q1803018
76+
77+
4. **Miran Shah** (id: 85611)
78+
- Coordinates: 33.00059°N, 70.07117°E
79+
- Native: میران شاہ
80+
- WikiData: Q124385
81+
82+
5. **North Wazīristān Agency** (id: 85645)
83+
- Coordinates: 32.95087°N, 69.95764°E
84+
- Native: شمالی وزیرستان ایجنسی
85+
- WikiData: Q2579925
86+
87+
6. **Shinpokh** (id: 85717)
88+
- Coordinates: 34.32959°N, 71.17852°E
89+
- Native: شن پوکھ
90+
- WikiData: Q1250069
91+
92+
7. **South Wazīristān Agency** (id: 85728)
93+
- Coordinates: 32.30397°N, 69.68207°E
94+
- Native: جنوبی وزیرستان ایجنسی
95+
- WikiData: Q7635235
96+
97+
8. **Wana** (id: 85764)
98+
- Coordinates: 32.29889°N, 69.57250°E
99+
- Native: وانا
100+
- WikiData: Q1026635
101+
102+
---
103+
104+
## Validation
105+
106+
### Database Integrity
107+
- ✅ Pakistan now has exactly 7 administrative divisions (per ISO 3166-2:PK)
108+
- ✅ All 8 former FATA cities successfully merged to Khyber Pakhtunkhwa
109+
- ✅ No cities reference the deleted FATA state (state_id: 3173)
110+
- ✅ All state_code values updated from "TA" to "KP"
111+
- ✅ All foreign key references (country_id, state_id) remain valid
112+
- ✅ JSON structure valid and consistent
113+
114+
### MySQL Database
115+
- ✅ States table: 7 Pakistan states (confirmed via query)
116+
- ✅ Cities table: 0 cities with state_id 3173 (FATA removed)
117+
- ✅ Cities table: 57 cities with state_id 3171 (Khyber Pakhtunkhwa)
118+
- ✅ Import/Export sync successful
119+
120+
### ISO 3166-2 Compliance
121+
- ✅ Matches official ISO 3166-2:PK subdivision codes
122+
- ✅ Aligns with Pakistan's 2018 constitutional amendment
123+
- ✅ Reflects current administrative reality
124+
125+
---
126+
127+
## Technical Implementation
128+
129+
### Files Modified
130+
1. **contributions/states/states.json**
131+
- Removed: 1 state (FATA, id: 3173)
132+
- Pakistan states: 8 → 7
133+
134+
2. **contributions/cities/PK.json**
135+
- Updated: 8 cities (changed state_id from 3173 to 3171)
136+
- Updated: 8 cities (changed state_code from "TA" to "KP")
137+
- Total Pakistan cities: 457 (unchanged)
138+
139+
### Commands Used
140+
```bash
141+
# Update cities from FATA to Khyber Pakhtunkhwa
142+
jq 'map(if .state_id == 3173 then .state_id = 3171 | .state_code = "KP" else . end)' \
143+
contributions/cities/PK.json > /tmp/PK_updated.json
144+
145+
# Remove FATA state
146+
jq 'map(select(.id != 3173))' contributions/states/states.json > /tmp/states_updated.json
147+
148+
# Import to MySQL
149+
python3 bin/scripts/sync/import_json_to_mysql.py --password root
150+
151+
# Sync back to JSON
152+
python3 bin/scripts/sync/sync_mysql_to_json.py --password root
153+
```
154+
155+
---
156+
157+
## Sources & References
158+
159+
- **ISO 3166-2:PK:** https://www.iso.org/obp/ui#iso:code:3166:PK
160+
- **Wikipedia - Pakistan:** https://en.wikipedia.org/wiki/Pakistan
161+
- **Wikipedia - FATA:** https://en.wikipedia.org/wiki/Federally_Administered_Tribal_Areas
162+
- **25th Constitutional Amendment (2018):** https://en.wikipedia.org/wiki/Twenty-fifth_Amendment_to_the_Constitution_of_Pakistan
163+
164+
---
165+
166+
## Quality Assurance
167+
168+
### Pre-Fix Verification
169+
```sql
170+
-- Before: 8 Pakistan states
171+
SELECT COUNT(*) FROM states WHERE country_code = 'PK'; -- Result: 8
172+
173+
-- Before: 8 FATA cities
174+
SELECT COUNT(*) FROM cities WHERE state_id = 3173; -- Result: 8
175+
176+
-- Before: 49 Khyber Pakhtunkhwa cities
177+
SELECT COUNT(*) FROM cities WHERE state_id = 3171; -- Result: 49
178+
```
179+
180+
### Post-Fix Verification
181+
```sql
182+
-- After: 7 Pakistan states
183+
SELECT COUNT(*) FROM states WHERE country_code = 'PK'; -- Result: 7
184+
185+
-- After: 0 FATA cities
186+
SELECT COUNT(*) FROM cities WHERE state_id = 3173; -- Result: 0
187+
188+
-- After: 57 Khyber Pakhtunkhwa cities
189+
SELECT COUNT(*) FROM cities WHERE state_id = 3171; -- Result: 57
190+
```
191+
192+
---
193+
194+
## Impact Assessment
195+
196+
- **Data Accuracy:** ✅ High - Aligns with official ISO 3166-2 standards
197+
- **Breaking Changes:** ⚠️ Minimal - Applications relying on FATA state_id 3173 will need updates
198+
- **Migration Path:** State_id 3173 removed; use state_id 3171 (Khyber Pakhtunkhwa) instead
199+
- **API Impact:** State queries for PK-TA will return no results (expected)
200+
201+
---
202+
203+
## Conclusion
204+
205+
This fix ensures the database accurately reflects Pakistan's current administrative structure as defined by ISO 3166-2:PK and the 2018 constitutional amendment merging FATA with Khyber Pakhtunkhwa. All 8 cities previously assigned to FATA are now correctly associated with Khyber Pakhtunkhwa province.

bin/db/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,6 @@ CREATE TABLE `cities` (
191191
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
192192
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
193193

194-
-- Dump completed on 2025-11-18 4:57:39
194+
-- Dump completed on 2025-11-18 5:33:40
195195

196196
SET FOREIGN_KEY_CHECKS=1;

contributions/cities/PK.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@
261261
{
262262
"id": 85336,
263263
"name": "Alizai",
264-
"state_id": 3173,
265-
"state_code": "TA",
264+
"state_id": 3171,
265+
"state_code": "KP",
266266
"country_id": 167,
267267
"country_code": "PK",
268268
"latitude": "33.53613000",
@@ -4664,8 +4664,8 @@
46644664
{
46654665
"id": 85458,
46664666
"name": "Gulishah Kach",
4667-
"state_id": 3173,
4668-
"state_code": "TA",
4667+
"state_id": 3171,
4668+
"state_code": "KP",
46694669
"country_id": 167,
46704670
"country_code": "PK",
46714671
"latitude": "32.67087000",
@@ -9030,8 +9030,8 @@
90309030
{
90319031
"id": 85577,
90329032
"name": "Landi Kotal",
9033-
"state_id": 3173,
9034-
"state_code": "TA",
9033+
"state_id": 3171,
9034+
"state_code": "KP",
90359035
"country_id": 167,
90369036
"country_code": "PK",
90379037
"latitude": "34.09880000",
@@ -10251,8 +10251,8 @@
1025110251
{
1025210252
"id": 85611,
1025310253
"name": "Miran Shah",
10254-
"state_id": 3173,
10255-
"state_code": "TA",
10254+
"state_id": 3171,
10255+
"state_code": "KP",
1025610256
"country_id": 167,
1025710257
"country_code": "PK",
1025810258
"latitude": "33.00059000",
@@ -11509,8 +11509,8 @@
1150911509
{
1151011510
"id": 85645,
1151111511
"name": "North Wazīristān Agency",
11512-
"state_id": 3173,
11513-
"state_code": "TA",
11512+
"state_id": 3171,
11513+
"state_code": "KP",
1151411514
"country_id": 167,
1151511515
"country_code": "PK",
1151611516
"latitude": "32.95087000",
@@ -14136,8 +14136,8 @@
1413614136
{
1413714137
"id": 85717,
1413814138
"name": "Shinpokh",
14139-
"state_id": 3173,
14140-
"state_code": "TA",
14139+
"state_id": 3171,
14140+
"state_code": "KP",
1414114141
"country_id": 167,
1414214142
"country_code": "PK",
1414314143
"latitude": "34.32959000",
@@ -14543,8 +14543,8 @@
1454314543
{
1454414544
"id": 85728,
1454514545
"name": "South Wazīristān Agency",
14546-
"state_id": 3173,
14547-
"state_code": "TA",
14546+
"state_id": 3171,
14547+
"state_code": "KP",
1454814548
"country_id": 167,
1454914549
"country_code": "PK",
1455014550
"latitude": "32.30397000",
@@ -15875,8 +15875,8 @@
1587515875
{
1587615876
"id": 85764,
1587715877
"name": "Wana",
15878-
"state_id": 3173,
15879-
"state_code": "TA",
15878+
"state_id": 3171,
15879+
"state_code": "KP",
1588015880
"country_id": 167,
1588115881
"country_code": "PK",
1588215882
"latitude": "32.29889000",

contributions/states/states.json

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -119934,48 +119934,6 @@
119934119934
"wikiDataId": "Q200130",
119935119935
"population": null
119936119936
},
119937-
{
119938-
"id": 3173,
119939-
"name": "Federally Administered Tribal Areas",
119940-
"country_id": 167,
119941-
"country_code": "PK",
119942-
"fips_code": "01",
119943-
"iso2": "TA",
119944-
"iso3166_2": "PK-TA",
119945-
"type": "administered area",
119946-
"level": null,
119947-
"parent_id": null,
119948-
"native": "وفاقی طور پر زیر انتظام قبائلی علاقوں",
119949-
"latitude": "33.02169390",
119950-
"longitude": "70.00844000",
119951-
"timezone": "Asia/Karachi",
119952-
"translations": {
119953-
"br": "Tachennoù meuriad meret gant ar Stadoù-Unanet",
119954-
"ko": "연방 행정 부족 지역",
119955-
"pt-BR": "Áreas tribais administradas pelo governo federal",
119956-
"pt": "Áreas tribais administradas pelo governo federal",
119957-
"nl": "Federaal bestuurde stamgebieden",
119958-
"hr": "Federalno upravljana plemenska područja",
119959-
"fa": "مناطق قبیله‌ای تحت مدیریت فدرال",
119960-
"de": "Stammesgebiete unter Bundesverwaltung",
119961-
"es": "Áreas tribales administradas por el gobierno federal",
119962-
"fr": "Zones tribales administrées par le gouvernement fédéral",
119963-
"ja": "連邦政府が管理する部族地域",
119964-
"it": "Aree tribali amministrate a livello federale",
119965-
"zh-CN": "联邦直辖部落地区",
119966-
"tr": "Federal Yönetimli Kabile Bölgeleri",
119967-
"ru": "Территории племен федерального управления",
119968-
"uk": "Федерально керовані племінні території",
119969-
"pl": "Obszary plemienne administrowane federalnie",
119970-
"hi": "संघीय प्रशासित जनजातीय क्षेत्र",
119971-
"ar": "المناطق القبلية الخاضعة للإدارة الفيدرالية"
119972-
},
119973-
"created_at": "2019-10-05T21:48:53",
119974-
"updated_at": "2025-10-09T12:02:19",
119975-
"flag": 1,
119976-
"wikiDataId": "Q208270",
119977-
"population": null
119978-
},
119979119937
{
119980119938
"id": 3174,
119981119939
"name": "Balochistan",

0 commit comments

Comments
 (0)