CREATE TABLE IF NOT EXISTS charges (
  id          INTEGER PRIMARY KEY AUTOINCREMENT,
  start_time  TEXT NOT NULL,      -- ISO 8601, lokale Zeit (Europe/Berlin)
  end_time    TEXT NOT NULL,
  duration_s  INTEGER NOT NULL,   -- aus cdi.value (ms/1000)
  energy_wh   REAL NOT NULL,      -- aus wh
  created_at  TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_charges_start ON charges(start_time);

CREATE TABLE IF NOT EXISTS meta (
  key   TEXT PRIMARY KEY,
  value TEXT
);
