laravel-countries icon indicating copy to clipboard operation
laravel-countries copied to clipboard

Migration not work on PostgreSQL

Open azulkipli opened this issue 8 years ago • 6 comments

Got this error when using PostgreSQL

syntax error at or near "MODIFY" LINE 1: ALTER TABLE countries MODIFY country_code CHAR(3) NOT NULL D... ^ (SQL: ALTER TABLE

azulkipli avatar Aug 05 '15 04:08 azulkipli

I have a branch ready with a fix for the Laravel 5 version (the Laravel 4 version doesn't support changing columns, but since the migrations are generated you are free to adjust the migration to support the database of your choice), however there is a bug in Laravel prohibiting me from releasing it: https://github.com/laravel/framework/issues/9636

paulkned avatar Aug 05 '15 07:08 paulkned

Do we need CharifyCountriesTable migration?

azulkipli avatar Aug 06 '15 04:08 azulkipli

No.. For lookups it can also use the included JSON file.

webpatser avatar Aug 06 '15 05:08 webpatser

@azulkipli for new projects: technically no, since all it does is ammend the first migration. However we want to be able to add migrations in the future and we want to be able to let users who are already using this package to be able to alter there existing setup rather than having them rollback the migrations and having to reinstall the whole thing...

paulkned avatar Aug 06 '15 07:08 paulkned

If technically not needed please make it to support exlcude CharifyCountriesTable when doing

php artisan countries:migration

thank you :)

azulkipli avatar Aug 20 '15 08:08 azulkipli

I fixed the query

DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " ALTER COLUMN country_code TYPE CHAR(3)");
DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " ALTER COLUMN iso_3166_2 TYPE CHAR(2)");
DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " ALTER COLUMN iso_3166_3 TYPE CHAR(3) ");
DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " ALTER COLUMN region_code TYPE CHAR(3)");
DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " ALTER COLUMN sub_region_code TYPE CHAR(3)");

davidjoan avatar Nov 11 '15 18:11 davidjoan