Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Clousure;
use RuntimeException;
use DB;

class Importer {

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
36 changes: 36 additions & 0 deletions src/migrations/2014_06_10_234941_geonames_utf8mb4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class GeonamesUtf8mb4 extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// requires MySQL >= 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');
}
}