Compatibilité MySQL + suppression de Redis comme dépendance requise
DbCompat (app/Support/DbCompat.php) : - like() → ilike (pgsql) ou like (mysql) - jsonRegexRaw() → data::text ~* ? (pgsql) ou CAST(data AS CHAR) REGEXP ? (mysql) - ftsRaw() → to_tsvector/plainto_tsquery (pgsql) ou null/fallback LIKE (mysql) - generatedJsonCol() → syntaxe colonne générée JSON selon le SGBD - generatedJsonNestedCol() → idem pour champs imbriqués Migrations : - create_releves_table : JSON/JSONB selon SGBD, colonnes générées adaptées, index GIN uniquement pour PostgreSQL Controllers : - LieuController (search + index) : ilike → DbCompat::like() - Admin\UserController (index) : ilike → DbCompat::like() - RechercheController : FTS + regex → DbCompat, fallback LIKE MySQL - ExportController : regex → DbCompat::jsonRegexRaw() UpdateService : - backupDatabase() : pg_dump (pgsql) ou mysqldump (mysql) - restoreBackup() : psql (pgsql) ou mysql (mysql) Docker : - docker-compose.yml : suppression Redis (plus requis) - docker-compose.mysql.yml : nouveau fichier pour dev MySQL - docker-compose.prod.yml : suppression Redis, DB_IMAGE configurable, CACHE_STORE/SESSION_DRIVER/QUEUE_CONNECTION → database par défaut .env.example : - DB_PORT commenté avec les deux valeurs (5432/3306) - CACHE_STORE et QUEUE_CONNECTION commentés (database par défaut) - Redis marqué optionnel Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Enums\SourceStatus;
|
||||
use App\Models\Releve;
|
||||
use App\Models\Source;
|
||||
use App\Services\GedcomExportService;
|
||||
use App\Support\DbCompat;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -50,15 +51,17 @@ class ExportController extends Controller
|
||||
}); // $request déjà dans le use()
|
||||
|
||||
if ($request->filled('q')) {
|
||||
$q = trim($request->get('q'));
|
||||
$query->where(function ($wq) use ($q) {
|
||||
$wq->where('nom', 'ilike', "%{$q}%")
|
||||
->orWhere('prenom','ilike', "%{$q}%")
|
||||
->orWhere('date_evenement', 'ilike', "%{$q}%")
|
||||
->orWhereRaw(
|
||||
"to_tsvector('french', data::text) @@ plainto_tsquery('french', ?)",
|
||||
[$q]
|
||||
);
|
||||
$q = trim($request->get('q'));
|
||||
$like = DbCompat::like();
|
||||
$fts = DbCompat::ftsRaw();
|
||||
|
||||
$query->where(function ($wq) use ($q, $like, $fts) {
|
||||
$wq->where('nom', $like, "%{$q}%")
|
||||
->orWhere('prenom', $like, "%{$q}%")
|
||||
->orWhere('date_evenement', $like, "%{$q}%");
|
||||
if ($fts) {
|
||||
$wq->orWhereRaw($fts, [$q]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,7 +79,7 @@ class ExportController extends Controller
|
||||
$noms = collect($rows)->pluck('nom')->filter();
|
||||
if ($noms->isNotEmpty()) {
|
||||
$pattern = $noms->map(fn ($n) => preg_quote($n, '/'))->join('|');
|
||||
$query->whereRaw("data::text ~* ?", [$pattern]);
|
||||
$query->whereRaw(DbCompat::jsonRegexRaw('data'), [$pattern]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user