diff options
Diffstat (limited to 'irc/db.rkt')
-rw-r--r-- | irc/db.rkt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/irc/db.rkt b/irc/db.rkt new file mode 100644 index 0000000..5cba0d3 --- /dev/null +++ b/irc/db.rkt @@ -0,0 +1,26 @@ +#lang racket/base +(require db sql) +(provide (all-defined-out)) + +; Assumption: Each connection gets its own database + +(define current-database (make-parameter #f)) + +(define (db-init) + (query-exec (current-database) + (create-table #:if-not-exists users + #:columns [name varchar #:not-null] + [power integer #:not-null] + [data varchar #:not-null] + #:constraints (primary-key name))) + + (query-exec (current-database) + (create-table #:if-not-exists channels + #:columns [name varchar #:not-null] + [autojoin boolean #:not-null] + [data varchar #:not-null])) + + (query-exec (current-database) + (create-table #:if-not-exists network + #:columns [name varchar #:not-null] + [data varchar #:not-null]))) |