Comments (4)
Just noticed this issue after switching from MySQL to Postgres. Postgres also has different format for altering tables, so the CharifyCountriesTable migration is not database agnostic and it works for MySQL only.
We would need to replace such raw SQL queries:
DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " MODIFY country_code CHAR(3) NOT NULL DEFAULT ''");
with something like:
$table->char('country_code', 3)->default('')->change();
However, the change() feature requires doctrine/dbal package installed and doctrine/dbal doesn't support CHAR type, as I understand. It means we can't charify the fields easily in all db types.
I see a couple of ways to address the problem:
- Write own raw SQL queries for each supported database in the CharifyCountriesTable migration and choose them depending on the used database type.
- Get rid of CharifyCountriesTable migration and only use char type in the main SetupCountriesTable migration so that all old users would use strings and all new users would use chars. Not a big difference.
- Get rid of CharifyCountriesTable and rollback SetupCountriesTable migration to creating fields of string type.
from laravel-countries.
I ended up using DB::raw
as an alternative for Sqlite and it seems to have worked as a workaround but it's not ideal.
from laravel-countries.
I used postgres as well. An example of 1.
if (Schema::getConnection()->getDriverName() == 'pgsql') {
} else {
}
from laravel-countries.
We can fix this by adding a char type to Doctrine. Check the open PR for the fix #120
from laravel-countries.
Related Issues (20)
- Number of decimals for currency missing for some countries HOT 1
- Seeder PHP exception
- Is it possible to get all regions?
- Seeding the countries table getting "Call to undefined method Webpatser\Countries\CountriesFacade::getList()" HOT 4
- 'CountriesSeeder' has no effect HOT 2
- not able to install your plugin HOT 1
- Deprecation notice for Composer v2.0: not-autoloading
- Country England not in the list why? HOT 1
- Support for Laravel 8 - Unable to open CountriesSeeder.php HOT 3
- Your configuration files are not serializable.
- Your code require an update in MigrationCommand
- Seeders folder instead seeds
- Missing options HOT 1
- Change Turkey's name to Türkiye
- Seeding 'CountriesSeeder.php' data did not work due to getList() called on Countries statically.
- Fix char migration for pgsql
- Data Correction
- Artisan optimize command is deprecated as of L5.5 and has already removed it from L5.6
- MTDF FILTER plugin not showing the result in wordpress
- Add pattern for phone
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-countries.