update burn-in schema
This commit is contained in:
1 parent
f5e4527b4b
commit
f27480b406
2 files changed
+25
-4
No files matched your search
+2
-1
@@ -86,7 +86,8 @@ CREATE TABLE IF NOT EXISTS payloads (
|
||||
|
||||
-- Baseline state at time of collection
|
||||
baseline_established INTEGER, -- bool
|
||||
baseline_samples INTEGER
|
||||
baseline_samples INTEGER,
|
||||
burn_in INTEGER -- bool
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_payloads_chamber ON payloads (chamber_id);
|
||||
|
||||
+23
-3
@@ -98,6 +98,23 @@ async def init_db(db_path: Path = DB_PATH) -> aiosqlite.Connection:
|
||||
await db.commit()
|
||||
current_version = 2
|
||||
|
||||
# ── Migration: v3 ────────────────────────────────────────────────────────
|
||||
# Adds burn_in column to payloads for UI calibration state on refresh.
|
||||
if current_version < 3:
|
||||
async with db.execute("PRAGMA table_info(payloads)") as cur:
|
||||
rows = await cur.fetchall()
|
||||
payload_cols = {row['name'] for row in rows}
|
||||
|
||||
if 'burn_in' not in payload_cols:
|
||||
await db.execute("ALTER TABLE payloads ADD COLUMN burn_in INTEGER")
|
||||
|
||||
await db.execute(
|
||||
"INSERT OR IGNORE INTO schema_version (version, description) VALUES (?, ?)",
|
||||
(3, 'Add burn_in column to payloads for UI calibration state'),
|
||||
)
|
||||
await db.commit()
|
||||
current_version = 3
|
||||
|
||||
log.info(f"Database ready — schema version {current_version} at {db_path}")
|
||||
return db
|
||||
|
||||
@@ -204,7 +221,7 @@ async def insert_payload(
|
||||
co2e_ppm, co2e_confidence, voc_ppb,
|
||||
z1_score, z2_score, z3_score,
|
||||
scd43_present, temp_delta, humidity_delta, temp_ok, humidity_ok,
|
||||
baseline_established, baseline_samples
|
||||
baseline_established, baseline_samples, burn_in
|
||||
) VALUES (
|
||||
?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?,
|
||||
@@ -213,7 +230,7 @@ async def insert_payload(
|
||||
?, ?, ?,
|
||||
?, ?, ?,
|
||||
?, ?, ?, ?, ?,
|
||||
?, ?
|
||||
?, ?, ?
|
||||
)
|
||||
""",
|
||||
(
|
||||
@@ -251,6 +268,7 @@ async def insert_payload(
|
||||
|
||||
int(raw.baseline.established),
|
||||
raw.baseline.n_samples,
|
||||
int(raw.burn_in),
|
||||
),
|
||||
) as cur:
|
||||
payload_id = cur.lastrowid
|
||||
@@ -493,7 +511,9 @@ async def get_environment_history(
|
||||
z2_score,
|
||||
z3_score,
|
||||
pressure_hpa,
|
||||
baseline_established
|
||||
baseline_established,
|
||||
baseline_samples,
|
||||
burn_in
|
||||
FROM payloads
|
||||
WHERE chamber_id = ? AND received_at >= ? AND ambient_valid = 1
|
||||
ORDER BY received_at ASC
|
||||
|
||||
Reference in new issue
Block a user