CREATE TABLE IF NOT EXISTS tb_card_daily_usage (
    id BIGSERIAL PRIMARY KEY,
    iot_card_id BIGINT NOT NULL,
    date DATE NOT NULL,
    usage_mb NUMERIC(12,2) NOT NULL DEFAULT 0,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW(),
    CONSTRAINT uk_card_daily UNIQUE (iot_card_id, date)
);
CREATE INDEX IF NOT EXISTS idx_card_daily_date ON tb_card_daily_usage (date);
