GithubHelp home page GithubHelp logo

Comments (4)

kkomelin avatar kkomelin commented on June 29, 2024 3

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:

  1. Write own raw SQL queries for each supported database in the CharifyCountriesTable migration and choose them depending on the used database type.
  2. 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.
  3. Get rid of CharifyCountriesTable and rollback SetupCountriesTable migration to creating fields of string type.

from laravel-countries.

Braunson avatar Braunson commented on June 29, 2024 2

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.

bryanrscott avatar bryanrscott commented on June 29, 2024

I used postgres as well. An example of 1.

if (Schema::getConnection()->getDriverName() == 'pgsql') {
} else {
}

from laravel-countries.

Dennis-Mwea avatar Dennis-Mwea commented on June 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.