diff options
Diffstat (limited to 'db')
| -rw-r--r-- | db/conn.rkt | 8 | ||||
| -rw-r--r-- | db/migrations.rkt | 10 |
2 files changed, 5 insertions, 13 deletions
diff --git a/db/conn.rkt b/db/conn.rkt index 2208e54..42a75c0 100644 --- a/db/conn.rkt +++ b/db/conn.rkt @@ -11,15 +11,11 @@ (define current-conn (make-parameter #f)) (define (connect! #:path [path 'memory]) - (cond - [(connection? (current-conn)) (printf "Database connection already exists: ~e\n" (current-conn))] - [else - (current-conn (sqlite3-connect #:database path #:mode 'create)) - (printf "Connected to database: ~a\n" path)])) + (unless (connection? (current-conn)) + (current-conn (sqlite3-connect #:database path #:mode 'create)))) (define (disconnect!) (disconnect (current-conn)) - (printf "Closing database connection: ~e\n" (current-conn)) (current-conn #f)) (define-syntax-rule (with-db body ...) diff --git a/db/migrations.rkt b/db/migrations.rkt index 0147210..dfa5c43 100644 --- a/db/migrations.rkt +++ b/db/migrations.rkt @@ -9,14 +9,10 @@ (define migrations-box (box '())) (define (migrate-all!) - (printf "Applying migrations on connection ~a...\n" - (dbsystem-name (connection-dbsystem (current-conn)))) (for ([pair (in-list (unbox migrations-box))]) - (match pair - [(cons migration-name stmts) - (with-tx (for ([stmt (in-list stmts)]) - (query-exec (current-conn) stmt))) - (printf "Applied migration: ~a\n" migration-name)]))) + (match-define (cons migration-name stmts) pair) + (with-tx (for ([stmt (in-list stmts)]) + (query-exec (current-conn) stmt))))) (define-syntax-rule (define-migration migration-name sql) (let ([migrations (unbox migrations-box)] |