CREATE TABLE IF NOT EXISTS user_real_work_summary (
    id SERIAL PRIMARY KEY,
    username VARCHAR(255) NOT NULL,
    work_date DATE NOT NULL,
    real_hours_counted INTEGER NOT NULL DEFAULT 0,
    last_processed_event_id INTEGER,
    last_event_completed_block BOOLEAN NOT NULL DEFAULT FALSE,
    CONSTRAINT uq_user_work_date UNIQUE (username, work_date)
);

-- Add any necessary indexes if performance testing indicates a need.
-- For example, an index on (username, work_date) is automatically created by the UNIQUE constraint.
-- An index on last_processed_event_id might be useful if queries filter by it frequently for unprocessed records.
-- CREATE INDEX IF NOT EXISTS idx_user_real_work_summary_last_processed ON user_real_work_summary(last_processed_event_id); 