annotate implementations/meredith/database-setup.lisp @ 215:4eceac78e7c6

add minimal backend for Dave Meredith's data Ignore-this: 91608f727967a4c5709bd41634ab9ae2 darcs-hash:20090524193956-16a00-038e6f7cb235dea4e7efcc70c4d1a7bc7fd402a6.gz committer: Jamie Forth <j.forth@gold.ac.uk>
author j.forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents
children
rev   line source
j@215 1 (cl:in-package #:amuse-meredith)
j@215 2
j@215 3 (defun create-meredith-tables (database)
j@215 4 (%create-compositions-table database)
j@215 5 (%create-events-table database))
j@215 6
j@215 7 (defun drop-meredith-tables (database)
j@215 8 (%drop-compositions-table database)
j@215 9 (%drop-events-table database))
j@215 10
j@215 11
j@215 12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@215 13 ;;; Helper functions
j@215 14
j@215 15 (defun %create-compositions-table (database)
j@215 16 #.(clsql:locally-enable-sql-reader-syntax)
j@215 17 (clsql:create-table "meredith_compositions"
j@215 18 '(([|composition-id|] clsql:smallint :unsigned
j@215 19 :not-null :auto-increment :primary-key)
j@215 20 ([|description|] (clsql:varchar 255)
j@215 21 :not-null))
j@215 22 :database database
j@215 23 :transactions t)
j@215 24 #.(clsql:locally-disable-sql-reader-syntax))
j@215 25
j@215 26 (defun %create-events-table (database)
j@215 27 #.(clsql:locally-enable-sql-reader-syntax)
j@215 28 (clsql:create-table "meredith_events"
j@215 29 '(([|composition-id|] clsql:smallint :unsigned
j@215 30 :not-null)
j@215 31 ([|event-id|] clsql:smallint :unsigned
j@215 32 :not-null :auto-increment :unique)
j@215 33 ([|tatum-on|] clsql:smallint :unsigned :not-null)
j@215 34 ([|pitch-name|] (clsql:varchar 32) :not-null)
j@215 35 ([|tatum-dur|] clsql:smallint :unsigned :not-null)
j@215 36 ([|voice|] clsql:smallint :unsigned :not-null)
j@215 37 ([|tactus-on|] clsql::float :unsigned :not-null)
j@215 38 ([|tactus-dur|] clsql::float :unsigned :not-null)
j@215 39 ([|crot-on|] clsql::float :unsigned :not-null)
j@215 40 ([|crot-dur|] clsql::float :unsigned :not-null)
j@215 41 ([|midi-note-number|] clsql:smallint :unsigned :not-null)
j@215 42 ([|chrom-pitch|] clsql:smallint :unsigned :not-null)
j@215 43 ([|morph-pitch|] clsql:smallint :unsigned :not-null)
j@215 44 ([|tatum-on-ms|] clsql:smallint :unsigned :not-null)
j@215 45 ([|tatum-dur-ms|] clsql:smallint :unsigned :not-null)
j@215 46 ([|beat-on-ms|] clsql:smallint :unsigned :not-null)
j@215 47 ([|beat-dur-ms|] clsql:smallint :unsigned :not-null)
j@215 48 ([|crot-on-ms|] clsql:smallint :unsigned :not-null)
j@215 49 ([|crot-dur-ms|] clsql:smallint :unsigned :not-null))
j@215 50 :constraints '("PRIMARY KEY (composition_id, event_id)")
j@215 51 :database database
j@215 52 :transactions t)
j@215 53 #.(clsql:locally-disable-sql-reader-syntax))
j@215 54
j@215 55 (defun %drop-compositions-table (database)
j@215 56 (clsql:drop-table "meredith_compositions"
j@215 57 :database database))
j@215 58
j@215 59 (defun %drop-events-table (database)
j@215 60 (clsql:drop-table "meredith_events"
j@215 61 :database database))