diff options
Diffstat (limited to 'src/db.lisp')
| -rw-r--r-- | src/db.lisp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/db.lisp b/src/db.lisp index 5d08e6a..8fab0db 100644 --- a/src/db.lisp +++ b/src/db.lisp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | (:export :get-inline-bot-type :set-inline-bot-type :with-db)) | 6 | (:export :get-inline-bot-type :set-inline-bot-type :with-db)) |
| 7 | (in-package :ukkoclot/db) | 7 | (in-package :ukkoclot/db) |
| 8 | 8 | ||
| 9 | (defparameter +target-version+ 1 | 9 | (defconstant +target-version+ 1 |
| 10 | "Intended DB version") | 10 | "Intended DB version") |
| 11 | 11 | ||
| 12 | (defmacro with-db ((name path) &body body) | 12 | (defmacro with-db ((name path) &body body) |
| @@ -20,7 +20,10 @@ | |||
| 20 | (integer->inline-bot-type type-int)))) | 20 | (integer->inline-bot-type type-int)))) |
| 21 | 21 | ||
| 22 | (defun set-inline-bot-type (db id type) | 22 | (defun set-inline-bot-type (db id type) |
| 23 | (execute-non-query db "INSERT OR REPLACE INTO inline_bots (id, type) VALUES (?, ?)" id (inline-bot-type->integer type))) | 23 | (execute-non-query db |
| 24 | "INSERT OR REPLACE INTO inline_bots (id, type) VALUES (?, ?)" | ||
| 25 | id | ||
| 26 | (inline-bot-type->integer type))) | ||
| 24 | 27 | ||
| 25 | (defun inline-bot-type->integer (type) | 28 | (defun inline-bot-type->integer (type) |
| 26 | (case type | 29 | (case type |
| @@ -66,8 +69,7 @@ | |||
| 66 | (execute-non-query db " | 69 | (execute-non-query db " |
| 67 | CREATE TABLE inline_bots_enum ( | 70 | CREATE TABLE inline_bots_enum ( |
| 68 | id INTEGER PRIMARY KEY, | 71 | id INTEGER PRIMARY KEY, |
| 69 | value TEXT UNIQUE | 72 | value TEXT UNIQUE)") |
| 70 | )") | ||
| 71 | (execute-non-query db " | 73 | (execute-non-query db " |
| 72 | INSERT INTO inline_bots_enum(id, value) | 74 | INSERT INTO inline_bots_enum(id, value) |
| 73 | VALUES (?, 'blacklisted'), (?, 'whitelisted')" | 75 | VALUES (?, 'blacklisted'), (?, 'whitelisted')" |
| @@ -78,6 +80,5 @@ VALUES (?, 'blacklisted'), (?, 'whitelisted')" | |||
| 78 | (execute-non-query db " | 80 | (execute-non-query db " |
| 79 | CREATE TABLE inline_bots ( | 81 | CREATE TABLE inline_bots ( |
| 80 | id INTEGER PRIMARY KEY, | 82 | id INTEGER PRIMARY KEY, |
| 81 | type INTEGER REFERENCES inline_bots_enum(id) | 83 | type INTEGER REFERENCES inline_bots_enum(id))")) |
| 82 | )")) | ||
| 83 | (t (error "Unreachable upgrade step reached ~A" new-version)))) | 84 | (t (error "Unreachable upgrade step reached ~A" new-version)))) |