khsing / laravel-world

provide countries, states, and cities relations and database.
MIT License
431 stars 90 forks source link

Can not `php artisan world:init' #3

Closed jamesriady closed 5 years ago

jamesriady commented 6 years ago

I have followed the step, but it occurs an error when I did php artisan world:init. I got this error Duplicate table: 7 ERROR: relation unique_locale has already exist I don't know why and I have checked all my table and I does not have the unique_locale

wildan-m commented 6 years ago

I've got this error

`Migration table not found. Migration table created successfully.

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table world_cities add index uniq_ci ty(country_id, division_id, name))

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes`

khsing commented 6 years ago

Might hit migration bugs, string can't be 256 long. I will take a look.

kotakorange commented 6 years ago

I have this error when do world:init SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF
0\x9F\x87\xB2\xF0\x9F...' for column 'emoji' at row 3

Deparagon commented 6 years ago

PDOException::("SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x8 7\xA8\xF0\x9F...' for column 'emoji' at row 1") Same error message ... I temporarily changed the column datatype to blob in the world_countries table... so that the seed can complete...

khsing commented 6 years ago

Hi @Deparagon @kotakorange, you have to use utf8mb4 for your database charset, otherwise you can't using emoji.

khsing commented 6 years ago

@wildanmuhlis2 you can add following lines in app/Providers/AppServiceProvider.php to avoid this error.

use Illuminate\Support\Facades\Schema;
...
    public function boot()
    {
        Schema::defaultStringLength(191);
    }
...
stephenlake commented 6 years ago

Why was this issue was closed? Users hijacked the issue with unrelated issues to the original poster and the issue is still present for postgres users.

There's a syntax issue in 3 migration files. A duplicate index name is generated for multiple columns:

CreateWorldContinentsLocaleTable.php: $table->unique(['continent_id','locale'], 'uniq_locale');

CreateWorldCountriesLocaleTable: $table->unique(['country_id','locale'], 'uniq_locale');

CreateWorldDivisionsTable.php: $table->unique(['country_id','name'], 'uniq_division');

You're giving multiple indexes the same name which breaks when using postgres. Index reference: https://laravel.com/docs/5.7/migrations#indexes

Again, I don't understand why this issue was closed when the following was never attended to:

I have followed the step, but it occurs an error when I did php artisan world:init. I got this error Duplicate table: 7 ERROR: relation unique_locale has already exist I don't know why and I have checked all my table and I does not have the unique_locale