kenepa / translation-manager

Manage your application's translations in Filament.
MIT License
89 stars 28 forks source link

Migrate error #13

Closed robin-dongbin closed 1 year ago

robin-dongbin commented 1 year ago

SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB, TEXT, GEOMETRY or JSON column 'text' can't have a default value

musa11971 commented 1 year ago

Hi, what database engine and version are you using?

robin-dongbin commented 1 year ago

innodb 8.0.29

mohssineAboutaj commented 1 year ago

in your config/database.php, change the value of engine in mysql connections to innodb

'engine' => 'innodb'
robin-dongbin commented 1 year ago

in your config/database.php, change the value of engine in mysql connections to innodb

'engine' => 'innodb'

Doesn't work

mohssineAboutaj commented 1 year ago

can you screen your migration ? i mean that language file

robin-dongbin commented 1 year ago

Just copied from the doc.

Schema::create('language_lines', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('group')->index();
    $table->string('key')->index();
    $table->json('text')->default('[]');
    $table->timestamps();
});
DevRaeph commented 1 year ago

Same

mohssineAboutaj commented 1 year ago

i think you need to upgrade, check here

musa11971 commented 1 year ago

Issue not related to the package

niccolofavari commented 1 year ago

As per Laravel Documentation

The default modifier accepts a value or an Illuminate\Database\Query\Expression instance. Using an Expression instance will prevent Laravel from wrapping the value in quotes and allow you to use database specific functions. One situation where this is particularly useful is when you need to assign default values to JSON columns

So the migration should be:

        Schema::create('language_lines', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('group')->index();
            $table->string('key')->index();
            $table->json('text')->default(new \Illuminate\Database\Query\Expression('(JSON_ARRAY())'));
            $table->timestamps();
        });

Hope this helps :)

paulohenriquesg commented 1 year ago

It really does help!

Maybe a PR to change the README would be nice :)

buzkall commented 1 year ago

I've done the PR -> https://github.com/kenepa/translation-manager/pull/20