Skip to content

Commit 858b460

Browse files
authored
Refactor world.sql: Clean up table drop statements, add timezone fiel… (#1076)
* Refactor world.sql: Clean up table drop statements, add timezone fields to cities and states, and update generation timestamp * Update world.sql: Increment city auto-increment value, adjust generation timestamp, and modify city names for consistency
1 parent edcf6ae commit 858b460

File tree

3 files changed

+156704
-157367
lines changed

3 files changed

+156704
-157367
lines changed

bin/Commands/ExportJson.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
143143
$statesArray[$i]['country_code'] = $state['country_code'];
144144
$statesArray[$i]['country_name'] = $state['country_name'];
145145
$statesArray[$i]['iso2'] = $state['iso2'];
146+
$statesArray[$i]['iso3166_2'] = $state['iso3166_2'];
146147
$statesArray[$i]['fips_code'] = $state['fips_code'];
147148
$statesArray[$i]['type'] = $state['type'];
148149
$statesArray[$i]['level'] = $state['level'];
@@ -155,9 +156,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
155156
'id' => $stateId,
156157
'name' => $stateName,
157158
'iso2' => $state['iso2'],
159+
'iso3166_2' => $state['iso3166_2'],
158160
'latitude' => $state['latitude'],
159161
'longitude' => $state['longitude'],
160-
'type' => $state['type']
162+
'type' => $state['type'],
163+
'timezone' => $state['timezone']
161164
);
162165

163166
array_push($stateNamesArray, $stateName);
@@ -183,14 +186,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
183186
$citiesArray[$j]['country_name'] = $countryName;
184187
$citiesArray[$j]['latitude'] = $city['latitude'];
185188
$citiesArray[$j]['longitude'] = $city['longitude'];
189+
$citiesArray[$j]['timezone'] = $city['timezone'];
186190
$citiesArray[$j]['wikiDataId'] = $city['wikiDataId'];
187191

188192
// For State City Array
189193
array_push($cityNamesArray, array(
190194
'id' => $cityId,
191195
'name' => $cityName,
192196
'latitude' => $city['latitude'],
193-
'longitude' => $city['longitude']
197+
'longitude' => $city['longitude'],
198+
'timezone' => $city['timezone']
194199
));
195200

196201
$j++;

bin/Commands/ExportSqlServer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,14 @@ private function generateTableSchema(string $table): string
9898
country_code NCHAR(2) NOT NULL,
9999
fips_code NVARCHAR(255) NULL,
100100
iso2 NVARCHAR(255) NULL,
101+
iso3166_2 NVARCHAR(10) NULL,
101102
type NVARCHAR(191) NULL,
103+
level INT NULL,
104+
parent_id INT NULL,
105+
native NVARCHAR(255) NULL,
102106
latitude DECIMAL(10,8) NULL,
103107
longitude DECIMAL(11,8) NULL,
108+
timezone NVARCHAR(255) NULL,
104109
created_at DATETIME2 NULL,
105110
updated_at DATETIME2 NOT NULL DEFAULT GETDATE(),
106111
flag BIT NOT NULL DEFAULT 1,
@@ -118,6 +123,7 @@ private function generateTableSchema(string $table): string
118123
country_code NCHAR(2) NOT NULL,
119124
latitude DECIMAL(10,8) NOT NULL,
120125
longitude DECIMAL(11,8) NOT NULL,
126+
timezone NVARCHAR(255) NULL,
121127
created_at DATETIME2 NOT NULL DEFAULT '2014-01-01 12:01:01',
122128
updated_at DATETIME2 NOT NULL DEFAULT GETDATE(),
123129
flag BIT NOT NULL DEFAULT 1,
@@ -164,7 +170,8 @@ private function generateSqlServerInsert(string $tableName, array $data): string
164170
protected function execute(InputInterface $input, OutputInterface $output): int
165171
{
166172
$io = new SymfonyStyle($input, $output);
167-
$rootDir = dirname(PATH_BASE);
173+
// Ensure PATH_BASE constant is resolved from global namespace
174+
$rootDir = dirname(\PATH_BASE);
168175

169176
$io->title('Exporting SQL Server data to ' . $rootDir);
170177

0 commit comments

Comments
 (0)