Created
August 1, 2021 10:35
-
-
Save jpswade/37ce66a1069739d16f49e42327830f70 to your computer and use it in GitHub Desktop.
Laravel - no such function: CONCAT sqlite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Traits; | |
use Illuminate\Database\SQLiteConnection; | |
use Illuminate\Support\Facades\DB; | |
trait SqliteTrait | |
{ | |
protected static function setUpSqlite(): void | |
{ | |
$db = DB::connection(); | |
if ($db instanceof SQLiteConnection) { | |
/** Fix: no such function: CONCAT */ | |
$db->getPdo() | |
->sqliteCreateFunction( | |
'concat', | |
function (...$input) { | |
return implode('', $input); | |
} | |
); | |
/** Fix: Cannot add a NOT NULL column with default value NULL */ | |
$db->getSchemaBuilder()->enableForeignKeyConstraints(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment