From 4767b145b2c39375fc81b62f640f488263803275 Mon Sep 17 00:00:00 2001 From: PaulVua Date: Mon, 1 Jun 2026 17:12:53 +0200 Subject: [PATCH] v1.9.19: S88/write_data.py - self-heal CREATE TABLE IF NOT EXISTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Protège contre le cas où l'OTA n'appelle pas create_db.py (problème bash classique: le script d'OTA est chargé en mémoire au lancement, le git pull du step 1 met à jour le fichier sur disque mais bash continue d'exécuter l'ancienne version). Le script crée la table data_S88 lui-même au démarrage. Schéma dupliqué de create_db.py — à garder synchro. Pattern à appliquer aux futurs capteurs pour éviter cette classe de bug. Co-Authored-By: Claude Opus 4.7 (1M context) --- S88/write_data.py | 9 +++++++++ VERSION | 2 +- changelog.json | 13 +++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/S88/write_data.py b/S88/write_data.py index a6cec79..287492a 100644 --- a/S88/write_data.py +++ b/S88/write_data.py @@ -83,6 +83,15 @@ def main(): conn = sqlite3.connect(DB_PATH) cursor = conn.cursor() + # Self-heal: ensure the table exists even if create_db.py was skipped during OTA. + # Duplicates the canonical schema from sqlite/create_db.py — keep them in sync. + cursor.execute(""" + CREATE TABLE IF NOT EXISTS data_S88 ( + timestamp TEXT, + CO2 INTEGER + ) + """) + port = get_config(cursor, "S88_port", DEFAULT_PORT) try: diff --git a/VERSION b/VERSION index f60acf7..88b883e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.18 +1.9.19 diff --git a/changelog.json b/changelog.json index 3378e16..d668854 100644 --- a/changelog.json +++ b/changelog.json @@ -1,5 +1,18 @@ { "versions": [ + { + "version": "1.9.19", + "date": "2026-06-01", + "changes": { + "features": [], + "improvements": [ + "S88/write_data.py: self-heal CREATE TABLE IF NOT EXISTS au démarrage. Protège contre le cas où l'OTA n'a pas appelé create_db.py (problème classique bash qui exécute l'ancien script chargé en mémoire avant le git pull). Le script crée la table data_S88 lui-même au 1er run si elle manque." + ], + "fixes": [], + "compatibility": [] + }, + "notes": "Le schéma de la table est dupliqué dans write_data.py et create_db.py — garder synchro. C'est volontaire pour rendre le script self-contained et éviter les blocages OTA. Pattern à appliquer aux futurs nouveaux capteurs." + }, { "version": "1.9.18", "date": "2026-06-01",