Skip to content

Commit

Permalink
feat(db): CHECK constraint on json columns
Browse files Browse the repository at this point in the history
The event_log now have CHECK constraints that check that the `meta` and `data`
fields are valid json.
  • Loading branch information
symbiont-daniel-gustafsson committed Feb 1, 2021
1 parent 8b71ab5 commit f6fb62d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/db/migrations/0_create_event_log.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
CREATE TABLE IF NOT EXISTS event_log (
id INTEGER PRIMARY KEY,
event TEXT NOT NULL,
meta JSON NOT NULL,
data JSON NOT NULL,
meta JSON NOT NULL CHECK(json_valid(meta)),
data JSON NOT NULL CHECK(json_valid(data)),
at DATETIME NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')));

-- +migrate Down
Expand Down

0 comments on commit f6fb62d

Please sign in to comment.