From 8f2c754ca73ff9d2e0b4ddf595c97f0963d41392 Mon Sep 17 00:00:00 2001 From: nitper Date: Tue, 10 Jun 2014 17:08:43 -0700 Subject: [PATCH] use utf8mb4 for names and altnames --- src/Importer.php | 3 ++ .../2014_06_10_234941_geonames_utf8mb4.php | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/migrations/2014_06_10_234941_geonames_utf8mb4.php diff --git a/src/Importer.php b/src/Importer.php index 175968f..7584e78 100644 --- a/src/Importer.php +++ b/src/Importer.php @@ -2,6 +2,7 @@ use Clousure; use RuntimeException; +use DB; class Importer { @@ -35,6 +36,7 @@ public function names($table, $path) $this->isEmpty($table); $repository = $this->repository; + DB::statement("SET NAMES 'utf8mb4'"); $this->parseFile($path, function($row) use ($table, $repository) { @@ -275,6 +277,7 @@ public function alternateNames($table, $path) $this->isEmpty($table); $repository = $this->repository; + DB::statement("SET NAMES 'utf8mb4'"); $this->parseFile($path, function($row) use ($table, $repository) { diff --git a/src/migrations/2014_06_10_234941_geonames_utf8mb4.php b/src/migrations/2014_06_10_234941_geonames_utf8mb4.php new file mode 100644 index 0000000..3abfc88 --- /dev/null +++ b/src/migrations/2014_06_10_234941_geonames_utf8mb4.php @@ -0,0 +1,36 @@ += 5.5 + DB::statement('ALTER TABLE geonames_alternate_names CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + DB::statement('ALTER TABLE geonames_alternate_names CHANGE alternate_name alternate_name VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + + DB::statement('ALTER TABLE geonames_names CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + DB::statement('ALTER TABLE geonames_names CHANGE name name VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::statement('ALTER TABLE geonames_alternate_names CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'); + DB::statement('ALTER TABLE geonames_alternate_names CHANGE alternate_name alternate_name VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci'); + + DB::statement('ALTER TABLE geonames_names CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'); + DB::statement('ALTER TABLE geonames_names CHANGE name name VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci'); + } +}