Files
worktimeBot/db/schema.sql
db123 c4e8c8dc3a fix: make schema idempotent with IF NOT EXISTS
Add i18n locale files to Docker image and fix all CREATE
statements to use IF NOT EXISTS to survive container restarts.
2026-06-23 21:42:39 +03:30

27 lines
719 B
SQL

CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS 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 IF NOT EXISTS 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())
);