Skip to content

Instantly share code, notes, and snippets.

@jpswade
Created August 1, 2021 10:35
Show Gist options
  • Save jpswade/37ce66a1069739d16f49e42327830f70 to your computer and use it in GitHub Desktop.
Save jpswade/37ce66a1069739d16f49e42327830f70 to your computer and use it in GitHub Desktop.
Laravel - no such function: CONCAT sqlite
<?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