diff --git a/api/database.php b/api/database.php index 271aa39..ee406dc 100644 --- a/api/database.php +++ b/api/database.php @@ -476,7 +476,6 @@ if (empty($recipeLibTables)) { ); "); } - // Recipe tags (v2.3) — tags pour trier/filtrer "Mes recettes", gérables depuis Config $recipeTagsTables = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='recipe_tags'")->fetchAll(); if (empty($recipeTagsTables)) { @@ -489,14 +488,6 @@ if (empty($recipeTagsTables)) { sort_order INTEGER DEFAULT 0 ); "); -} -// Migration: add keywords column to recipe_tags if missing -$rtCols = array_column($db->query("PRAGMA table_info(recipe_tags)")->fetchAll(), 'name'); -if (!in_array('keywords', $rtCols)) { - try { $db->exec("ALTER TABLE recipe_tags ADD COLUMN keywords TEXT DEFAULT ''"); } - catch (PDOException $e) { if (strpos($e->getMessage(), 'duplicate column') === false) throw $e; } -} - $db->exec("INSERT INTO recipe_tags (key, label, icon, sort_order) VALUES ('cocktail', 'Cocktail', '🍹', 1), ('sans_alcool', 'Sans alcool', '🚫', 2), @@ -523,6 +514,13 @@ if (!in_array('keywords', $rtCols)) { ('brunch', 'Brunch', '🥂', 23) "); } +// Migration: add keywords column to recipe_tags if missing +$rtCols = array_column($db->query("PRAGMA table_info(recipe_tags)")->fetchAll(), 'name'); +if (!in_array('keywords', $rtCols)) { + try { $db->exec("ALTER TABLE recipe_tags ADD COLUMN keywords TEXT DEFAULT ''"); } + catch (PDOException $e) { if (strpos($e->getMessage(), 'duplicate column') === false) throw $e; } +} + // Custom quantity units (v2.4) — unités personnalisées (ex: kg, L) avec facteur de conversion vers pz/g/ml, gérables depuis Config $customUnitsTables = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='custom_units'")->fetchAll(); if (empty($customUnitsTables)) {