annotate base/database/implementations-setup.lisp @ 330:2fbff655ba47 tip

Removed cpitch-adj and cents SQL columns
author Jeremy Gow <jeremy.gow@gmail.com>
date Mon, 21 Jan 2013 11:08:11 +0000
parents 2519652145c3
children 6a3adca16910
rev   line source
j@287 1 (cl:in-package #:amuse-database-admin)
j@287 2
j@287 3 (defun create-implementations-table (&optional
j@287 4 (database *amuse-database*))
j@287 5 (%create-implementations-table database)
j@287 6 (%create-implementation-stored-routines database))
j@287 7
j@287 8 (defun drop-implementations-table (&optional
j@287 9 (database *amuse-database*))
j@287 10 (%drop-implementations-table database)
j@287 11 (%drop-implementation-stored-routines database))
j@287 12
j@287 13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@287 14 ;;; Helper functions
j@287 15
j@287 16 (defun %create-implementations-table (database)
j@287 17 #.(clsql:locally-enable-sql-reader-syntax)
j@287 18 (clsql:create-table "amuse_implementations"
j@287 19 '(([|implementation-id|] clsql:smallint :unsigned
j@287 20 :not-null :auto-increment :primary-key)
j@287 21 ([|implementation-name|] (varchar 255)
j@287 22 :not-null :unique))
j@287 23 :database database
j@287 24 :transactions t)
j@287 25 #.(clsql:locally-disable-sql-reader-syntax))
j@287 26
j@287 27 (defun %drop-implementations-table (database)
j@287 28 (clsql:drop-table "amuse_implementations"
j@287 29 :if-does-not-exist :ignore
j@287 30 :database database))
j@287 31
j@287 32 (defun %create-implementation-stored-routines (database)
j@287 33 (%create-db-fun-get-impl-id database)
j@287 34 (%create-db-fun-get-impl-name database))
j@287 35
j@287 36 (defun %drop-implementation-stored-routines (database)
j@287 37 (%drop-db-fun-get-impl-id database)
j@287 38 (%drop-db-fun-get-impl-name database))
j@287 39
j@287 40 (defun %create-db-fun-get-impl-id (database)
j@287 41 (clsql:execute-command "
j@287 42 CREATE FUNCTION get_impl_id (
j@287 43 impl_name VARCHAR(255))
j@287 44 RETURNS SMALLINT
j@289 45 READS SQL DATA
j@287 46 RETURN (SELECT implementation_id
j@287 47 FROM amuse_implementations
j@287 48 WHERE implementation_name = impl_name);"
j@287 49 :database database))
j@287 50
j@287 51 (defun %drop-db-fun-get-impl-id (database)
j@287 52 (clsql:execute-command "
j@287 53 DROP FUNCTION get_impl_id"
j@287 54 :database database))
j@287 55
j@287 56 (defun %create-db-fun-get-impl-name (database)
j@287 57 (clsql:execute-command "
j@287 58 CREATE FUNCTION get_impl_name (
j@287 59 impl_id SMALLINT)
j@287 60 RETURNS VARCHAR(255)
j@289 61 READS SQL DATA
j@287 62 RETURN (SELECT implementation_name
j@287 63 FROM amuse_implementations
j@287 64 WHERE implementation_id = impl_id);"
j@287 65 :database database))
j@287 66
j@287 67 (defun %drop-db-fun-get-impl-name (database)
j@287 68 (clsql:execute-command "
j@287 69 DROP FUNCTION get_impl_name"
j@287 70 :database database))