Rend les salles et tournées configurables

Refs #10 #21
This commit is contained in:
Alexandre NOEL 2026-09-08 00:33:25 +02:00
commit e7176b6371
17 changed files with 189 additions and 25 deletions

View file

@ -65,14 +65,27 @@ final class Migrations
}
}
$relaxesForeignKeys = $name === '093_room_rules_and_care_periods.sql';
if ($relaxesForeignKeys) {
$db->exec('PRAGMA foreign_keys = OFF');
}
$db->beginTransaction();
try {
$db->exec($sql);
$ins = $db->prepare("INSERT INTO _migrations(name, applied_at) VALUES(:n, datetime('now'))");
$ins->execute([':n' => $name]);
if ($relaxesForeignKeys && $db->query('PRAGMA foreign_key_check')->fetchColumn() !== false) {
throw new RuntimeException('Foreign key check failed after room migration');
}
$db->commit();
if ($relaxesForeignKeys) {
$db->exec('PRAGMA foreign_keys = ON');
}
} catch (Throwable $e) {
$db->rollBack();
if ($relaxesForeignKeys) {
$db->exec('PRAGMA foreign_keys = ON');
}
throw new RuntimeException('Migration ' . $name . ' : ' . $e->getMessage(), 0, $e);
}
}