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

@ -601,7 +601,7 @@ trait AnimalBrowseActions
$ref_med_administration = $db
->query('SELECT id, name, accro FROM ref_med_administration ORDER BY id')
->fetchAll();
$vaccines = $db->query('SELECT id, name, code FROM ref_vaccines ORDER BY id')->fetchAll();
$vaccines = $db->query('SELECT id, name FROM ref_vaccines ORDER BY id')->fetchAll();
$inventoryBatches = $db
->query(
'SELECT b.id,b.batch_number,b.expires_on,b.quantity,p.name,p.unit,p.category,p.reference_id FROM inventory_batches b JOIN inventory_products p ON p.id=b.product_id WHERE b.quantity>0 AND p.active=1 ORDER BY p.category,p.name COLLATE NOCASE,date(b.expires_on)',

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);