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.
This commit is contained in:
@@ -20,6 +20,7 @@ WORKDIR /data
|
||||
|
||||
COPY --from=builder /usr/local/bin/worktime-bot /usr/local/bin/worktime-bot
|
||||
COPY --from=builder /src/db/schema.sql ./db/schema.sql
|
||||
COPY --from=builder /src/pkg/i18n/ ./i18n/
|
||||
|
||||
VOLUME ["/data"]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE events (
|
||||
CREATE TABLE IF NOT EXISTS events (
|
||||
id INTEGER PRIMARY KEY,
|
||||
event_type TEXT NOT NULL
|
||||
CHECK (event_type IN ('in', 'out')),
|
||||
@@ -9,7 +9,7 @@ CREATE TABLE events (
|
||||
DEFAULT (unixepoch())
|
||||
);
|
||||
|
||||
CREATE INDEX idx_events_occurred_at
|
||||
CREATE INDEX IF NOT EXISTS idx_events_occurred_at
|
||||
ON events(occurred_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS settings (
|
||||
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS settings (
|
||||
value TEXT NOT NULL DEFAULT ''
|
||||
);
|
||||
|
||||
CREATE TABLE days_off (
|
||||
CREATE TABLE IF NOT EXISTS days_off (
|
||||
date TEXT PRIMARY KEY
|
||||
CHECK (date = strftime('%Y-%m-%d', date)),
|
||||
reason TEXT NOT NULL DEFAULT '',
|
||||
|
||||
Reference in New Issue
Block a user