Réparer l’ouverture des fiches animales

This commit is contained in:
Alexandre NOEL 2026-09-04 12:06:23 +02:00
commit 72438556cd
4 changed files with 70 additions and 1 deletions

View file

@ -47,6 +47,24 @@ final class Migrations
}
}
// Les anciennes bases possédaient déjà le nouvel historique alors
// que les installations neuves recevaient encore son premier schéma.
if ($name === '090_medication_administration_routes.sql') {
$columns = array_column(
$db->query('PRAGMA table_info(animal_history)')->fetchAll(PDO::FETCH_ASSOC),
'name',
);
if (!in_array('type', $columns, true)) {
$db->exec("ALTER TABLE animal_history ADD COLUMN type TEXT NOT NULL DEFAULT 'history'");
}
if (!in_array('label', $columns, true)) {
$db->exec("ALTER TABLE animal_history ADD COLUMN label TEXT NOT NULL DEFAULT ''");
}
if (!in_array('details', $columns, true)) {
$db->exec('ALTER TABLE animal_history ADD COLUMN details TEXT');
}
}
$db->beginTransaction();
try {
$db->exec($sql);