summaryrefslogtreecommitdiff
path: root/irc/db.rkt
blob: 5cba0d32e4833daaea60f0f175dd97fb1ef7c924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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])))