Skip to content

Commit

Permalink
adjust model definition to initialize DB if it does not exist yet
Browse files Browse the repository at this point in the history
  • Loading branch information
mck- committed Apr 30, 2012
1 parent 0555e5e commit 823a47e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/util/model-utils.lisp
Expand Up @@ -10,11 +10,9 @@
,@slot-definitions)
(:metaclass dao-class)
(:keys id))
(defun ,(symb name 'init-table) ()
(with-connection (db-params)
(when (table-exists-p ',name)
(query (conc "DROP TABLE" (string ',name))))
(execute (dao-table-definition ',name))))
(with-connection (db-params)
(unless (table-exists-p ',name)
(execute (dao-table-definition ',name))))
;; Create
(defmacro ,(symb name 'create) (&rest args)
`(with-connection (db-params)
Expand Down

0 comments on commit 823a47e

Please sign in to comment.