discordBots/schema.sql
2024-07-12 13:53:17 +00:00

15 lines
No EOL
444 B
SQL

CREATE TABLE IF NOT EXISTS store
(
id TEXT NOT NULL PRIMARY KEY,
data BLOB NOT NULL,
created_at DATE NOT NULL DEFAULT current_timestamp,
updated_at DATE NOT NULL DEFAULT current_timestamp
);
-- automatic updated at
CREATE TRIGGER IF NOT EXISTS update_store_updated_at
AFTER UPDATE ON store
WHEN OLD.updated_at <> current_timestamp
BEGIN
UPDATE store SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
END;