DB migration dans set_config.py (execute a chaque update)
Ajoute la colonne npm_status a data_NPM via ALTER TABLE. Place dans set_config.py car c'est le seul script DB appele par les scripts d'update (create_db.py n'est pas appele). Liste de migrations extensible pour les futurs ajouts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,18 @@ for connected, port, name, coefficient in envea_sondes:
|
|||||||
print(f"Envea sonde '{name}' already exists, skipping")
|
print(f"Envea sonde '{name}' already exists, skipping")
|
||||||
|
|
||||||
|
|
||||||
|
# Database migrations (add columns to existing tables)
|
||||||
|
migrations = [
|
||||||
|
("data_NPM", "npm_status", "INTEGER DEFAULT 0"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for table, column, col_type in migrations:
|
||||||
|
try:
|
||||||
|
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} {col_type}")
|
||||||
|
print(f"Migration: added column '{column}' to {table}")
|
||||||
|
except:
|
||||||
|
pass # Column already exists
|
||||||
|
|
||||||
# Commit and close the connection
|
# Commit and close the connection
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user