BEGIN TRANSACTION;

-- Create Zever tables
CREATE TABLE ZeverLogs (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Date TEXT NOT NULL, TimeUtc TEXT NOT NULL, CurrentWatts INTEGER NOT NULL, TotalWatts BIGINT NOT NULL);
CREATE INDEX idx_ZeverLogs_Date ON ZeverLogs (Date);
CREATE INDEX idx_ZeverLogs_TimeUtc ON ZeverLogs (TimeUtc);
CREATE INDEX idx_ZeverLogs_TotalWatts ON ZeverLogs (TotalWatts);

CREATE TABLE ZeverSummary (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Date TEXT NOT NULL UNIQUE, TotalWatts BIGINT NOT NULL);
CREATE UNIQUE INDEX idx_ZeverSummary_Date on ZeverSummary (Date);

-- Create Envoy table
CREATE TABLE EnvoyLogs (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Date TEXT NOT NULL, TimeUtc TEXT NOT NULL, CurrentWatts INTEGER NOT NULL, TotalWatts BIGINT NOT NULL, Inverters INTEGER NOT NULL);
CREATE INDEX idx_EnvoyLogs_Date ON EnvoyLogs (Date);
CREATE INDEX idx_EnvoyLogs_TimeUtc ON EnvoyLogs (TimeUtc);
CREATE INDEX idx_EnvoyLogs_TotalWatts ON EnvoyLogs (TotalWatts);

COMMIT;
