comparison 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
comparison
equal deleted inserted replaced
214:545f80a73f03 215:4eceac78e7c6
1 (cl:in-package #:amuse-meredith)
2
3 (defun create-meredith-tables (database)
4 (%create-compositions-table database)
5 (%create-events-table database))
6
7 (defun drop-meredith-tables (database)
8 (%drop-compositions-table database)
9 (%drop-events-table database))
10
11
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 ;;; Helper functions
14
15 (defun %create-compositions-table (database)
16 #.(clsql:locally-enable-sql-reader-syntax)
17 (clsql:create-table "meredith_compositions"
18 '(([|composition-id|] clsql:smallint :unsigned
19 :not-null :auto-increment :primary-key)
20 ([|description|] (clsql:varchar 255)
21 :not-null))
22 :database database
23 :transactions t)
24 #.(clsql:locally-disable-sql-reader-syntax))
25
26 (defun %create-events-table (database)
27 #.(clsql:locally-enable-sql-reader-syntax)
28 (clsql:create-table "meredith_events"
29 '(([|composition-id|] clsql:smallint :unsigned
30 :not-null)
31 ([|event-id|] clsql:smallint :unsigned
32 :not-null :auto-increment :unique)
33 ([|tatum-on|] clsql:smallint :unsigned :not-null)
34 ([|pitch-name|] (clsql:varchar 32) :not-null)
35 ([|tatum-dur|] clsql:smallint :unsigned :not-null)
36 ([|voice|] clsql:smallint :unsigned :not-null)
37 ([|tactus-on|] clsql::float :unsigned :not-null)
38 ([|tactus-dur|] clsql::float :unsigned :not-null)
39 ([|crot-on|] clsql::float :unsigned :not-null)
40 ([|crot-dur|] clsql::float :unsigned :not-null)
41 ([|midi-note-number|] clsql:smallint :unsigned :not-null)
42 ([|chrom-pitch|] clsql:smallint :unsigned :not-null)
43 ([|morph-pitch|] clsql:smallint :unsigned :not-null)
44 ([|tatum-on-ms|] clsql:smallint :unsigned :not-null)
45 ([|tatum-dur-ms|] clsql:smallint :unsigned :not-null)
46 ([|beat-on-ms|] clsql:smallint :unsigned :not-null)
47 ([|beat-dur-ms|] clsql:smallint :unsigned :not-null)
48 ([|crot-on-ms|] clsql:smallint :unsigned :not-null)
49 ([|crot-dur-ms|] clsql:smallint :unsigned :not-null))
50 :constraints '("PRIMARY KEY (composition_id, event_id)")
51 :database database
52 :transactions t)
53 #.(clsql:locally-disable-sql-reader-syntax))
54
55 (defun %drop-compositions-table (database)
56 (clsql:drop-table "meredith_compositions"
57 :database database))
58
59 (defun %drop-events-table (database)
60 (clsql:drop-table "meredith_events"
61 :database database))