(asdf:oos 'asdf:load-op :clsql) (asdf:operate 'asdf:load-op :clsql-postgresql) (defpackage brew-db (:use common-lisp) (:use clsql) (:export style master-recipe recipe-revision hop grain yeast)) (in-package brew-db) (use-package 'clsql) #.(locally-enable-sql-reader-syntax) (defvar *connection* (connect '("" "homebrew" "clinton" "") :database-type :postgresql :if-exists :old)) (def-view-class style () ((id :type integer :db-kind :key :initarg :id) (name :type varchar :initarg :name) (og-low :type float :initarg :og-low) (og-high :type float :initarg :og-high) (fg-low :type float :initarg :fg-low) (fg-high :type float :initarg :fg-high) (ibu-low :type integer :initarg :ibu-low) (ibu-high :type integer :initarg :ibu-high) (srm-low :type integer :initarg :srm-low) (srm-high :type integer :initarg :srm-high))) (def-view-class master-recipe () ((name :type (varchar 64) :db-kind :key) (description :type varchar) (style :db-kind :join :db-info (:join-class style :home-key style-id :foreign-key id :set nil)))) (def-view-class recipe-revision () ((id :type integer :db-kind :key) (recipe :db-kind :join :db-info (:join-class master-recipe :home-key recipe-name :foreign-key name)) (revision :type integer))) (def-view-class hop () ((id :type integer :db-kind :key) (name :type varchar) (alpha :type float))) (def-view-class grain () ((id :initarg :id :type integer :db-kind :key) (name :initarg :name :type varchar) (color :initarg :color :type integer) (extract :initarg :extract :type float) (use :initarg :use :type (varchar 64)))) (def-view-class yeast () ((id :type integer :db-kind :key) (name :type varchar)))