-- Truck dump stats cache table
-- Run on: 192.168.0.10 / controls database

CREATE TABLE IF NOT EXISTS truckdump_stats_cache (
    id                  INT PRIMARY KEY DEFAULT 1,
    
    -- East (totnorth) stats
    east_since_last     VARCHAR(20),
    east_between_dumps  VARCHAR(20),
    east_avg_10         VARCHAR(20),
    
    -- West 1 (totsouth) stats
    west1_since_last    VARCHAR(20),
    west1_between_dumps VARCHAR(20),
    west1_avg_10        VARCHAR(20),
    
    -- West 2 (totwest2) stats
    west2_since_last    VARCHAR(20),
    west2_between_dumps VARCHAR(20),
    west2_avg_10        VARCHAR(20),
    
    -- Metadata
    updated_at          DATETIME NOT NULL,
    
    -- Ensure only one row
    CONSTRAINT single_row CHECK (id = 1)
);

-- Insert initial row
INSERT IGNORE INTO truckdump_stats_cache (id, updated_at)
VALUES (1, NOW());
