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\Lieu;
|
||||
use App\Models\Releve;
|
||||
use App\Models\SourceType;
|
||||
use App\Support\DbCompat;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\View\View;
|
||||
@@ -50,15 +51,18 @@ class RechercheController extends Controller
|
||||
|
||||
// ── Recherche textuelle ──────────────────────────────────────────────
|
||||
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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,11 +70,10 @@ class RechercheController extends Controller
|
||||
if ($request->filled('lieu_id')) {
|
||||
$lieuNoms = $this->getLieuNoms($request->integer('lieu_id'));
|
||||
if ($lieuNoms->isNotEmpty()) {
|
||||
// Recherche regex case-insensitive dans le JSONB text
|
||||
$pattern = $lieuNoms
|
||||
->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