CREATE TABLE events (
    id INTEGER PRIMARY KEY,
    event_type TEXT NOT NULL
        CHECK (event_type IN ('in', 'out')),
    occurred_at INTEGER NOT NULL UNIQUE
          CHECK (occurred_at > 0),
      note TEXT NOT NULL DEFAULT '',
    created_at INTEGER NOT NULL
          DEFAULT (unixepoch())
);

CREATE INDEX idx_events_occurred_at
ON events(occurred_at);

CREATE TABLE IF NOT EXISTS settings (
    key   TEXT PRIMARY KEY,
    value TEXT NOT NULL DEFAULT ''
);

CREATE TABLE days_off (
    date TEXT PRIMARY KEY
          CHECK (date = strftime('%Y-%m-%d', date)),
    reason TEXT NOT NULL DEFAULT '',
    created_at INTEGER NOT NULL
          DEFAULT (unixepoch())
);
