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:
@@ -206,21 +206,30 @@ class UpdateService
|
||||
throw new RuntimeException("Fichier introuvable : {$path}");
|
||||
}
|
||||
|
||||
$host = config('database.connections.pgsql.host');
|
||||
$port = config('database.connections.pgsql.port', 5432);
|
||||
$db = config('database.connections.pgsql.database');
|
||||
$user = config('database.connections.pgsql.username');
|
||||
$password = config('database.connections.pgsql.password');
|
||||
$driver = config('database.default');
|
||||
$conn = config("database.connections.{$driver}");
|
||||
|
||||
$cmd = sprintf(
|
||||
'PGPASSWORD=%s psql -h %s -p %s -U %s %s < %s',
|
||||
escapeshellarg($password),
|
||||
escapeshellarg($host),
|
||||
(int) $port,
|
||||
escapeshellarg($user),
|
||||
escapeshellarg($db),
|
||||
escapeshellarg($path),
|
||||
);
|
||||
if ($driver === 'pgsql') {
|
||||
$cmd = sprintf(
|
||||
'PGPASSWORD=%s psql -h %s -p %s -U %s %s < %s',
|
||||
escapeshellarg($conn['password']),
|
||||
escapeshellarg($conn['host']),
|
||||
(int) ($conn['port'] ?? 5432),
|
||||
escapeshellarg($conn['username']),
|
||||
escapeshellarg($conn['database']),
|
||||
escapeshellarg($path),
|
||||
);
|
||||
} else {
|
||||
$cmd = sprintf(
|
||||
'mysql -h %s -P %s -u %s %s %s < %s',
|
||||
escapeshellarg($conn['host']),
|
||||
(int) ($conn['port'] ?? 3306),
|
||||
escapeshellarg($conn['username']),
|
||||
$conn['password'] ? '-p' . escapeshellarg($conn['password']) : '',
|
||||
escapeshellarg($conn['database']),
|
||||
escapeshellarg($path),
|
||||
);
|
||||
}
|
||||
|
||||
Artisan::call('down');
|
||||
$this->exec($cmd);
|
||||
@@ -238,27 +247,35 @@ class UpdateService
|
||||
|
||||
$filename = "db-before-{$version}-" . date('Ymd-His') . ".sql";
|
||||
$path = "{$dir}/{$filename}";
|
||||
$driver = config('database.default');
|
||||
$conn = config("database.connections.{$driver}");
|
||||
|
||||
$host = config('database.connections.pgsql.host');
|
||||
$port = config('database.connections.pgsql.port', 5432);
|
||||
$db = config('database.connections.pgsql.database');
|
||||
$user = config('database.connections.pgsql.username');
|
||||
$password = config('database.connections.pgsql.password');
|
||||
|
||||
$cmd = sprintf(
|
||||
'PGPASSWORD=%s pg_dump -h %s -p %s -U %s %s > %s',
|
||||
escapeshellarg($password),
|
||||
escapeshellarg($host),
|
||||
(int) $port,
|
||||
escapeshellarg($user),
|
||||
escapeshellarg($db),
|
||||
escapeshellarg($path),
|
||||
);
|
||||
if ($driver === 'pgsql') {
|
||||
$cmd = sprintf(
|
||||
'PGPASSWORD=%s pg_dump -h %s -p %s -U %s %s > %s',
|
||||
escapeshellarg($conn['password']),
|
||||
escapeshellarg($conn['host']),
|
||||
(int) ($conn['port'] ?? 5432),
|
||||
escapeshellarg($conn['username']),
|
||||
escapeshellarg($conn['database']),
|
||||
escapeshellarg($path),
|
||||
);
|
||||
} else {
|
||||
$cmd = sprintf(
|
||||
'mysqldump -h %s -P %s -u %s %s %s > %s',
|
||||
escapeshellarg($conn['host']),
|
||||
(int) ($conn['port'] ?? 3306),
|
||||
escapeshellarg($conn['username']),
|
||||
$conn['password'] ? '-p' . escapeshellarg($conn['password']) : '',
|
||||
escapeshellarg($conn['database']),
|
||||
escapeshellarg($path),
|
||||
);
|
||||
}
|
||||
|
||||
$this->exec($cmd);
|
||||
|
||||
if (! file_exists($path) || filesize($path) === 0) {
|
||||
throw new RuntimeException("La sauvegarde PostgreSQL a échoué (pg_dump disponible dans le container ?)");
|
||||
throw new RuntimeException("La sauvegarde de la base de données a échoué ({$driver}).");
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
||||
Reference in New Issue
Block a user