Mercurial > hg > amuse
comparison base/database/implementations-setup.lisp @ 216:e1842efb1dd4
amuse-database-admin add implementation and dataset functionality
Ignore-this: 787cc01acf2d6a58640fec017de16c17
darcs-hash:20090716145807-16a00-6fe5ad4a2b6252b2c1f3d109a16455bb32243965.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 | 385935631532 |
comparison
equal
deleted
inserted
replaced
215:4eceac78e7c6 | 216:e1842efb1dd4 |
---|---|
1 (cl:in-package #:amuse-database-admin) | |
2 | |
3 (defun create-implementations-table (&optional | |
4 (database *amuse-database*)) | |
5 (%create-implementations-table database) | |
6 (%create-implementation-stored-routines database)) | |
7 | |
8 (defun drop-implementations-table (&optional | |
9 (database *amuse-database*)) | |
10 (%drop-implementations-table database) | |
11 (%drop-implementation-stored-routines database)) | |
12 | |
13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
14 ;;; Helper functions | |
15 | |
16 (defun %create-implementations-table (database) | |
17 #.(clsql:locally-enable-sql-reader-syntax) | |
18 (clsql:create-table "amuse_implementations" | |
19 '(([|implementation-id|] clsql:smallint :unsigned | |
20 :not-null :auto-increment :primary-key) | |
21 ([|implementation-name|] (varchar 255) | |
22 :not-null :unique)) | |
23 :database database | |
24 :transactions t) | |
25 #.(clsql:locally-disable-sql-reader-syntax)) | |
26 | |
27 (defun %drop-implementations-table (database) | |
28 (clsql:drop-table "amuse_implementations" | |
29 :if-does-not-exist :ignore | |
30 :database database)) | |
31 | |
32 (defun %create-implementation-stored-routines (database) | |
33 (%create-db-fun-get-impl-id database) | |
34 (%create-db-fun-get-impl-name database)) | |
35 | |
36 (defun %drop-implementation-stored-routines (database) | |
37 (%drop-db-fun-get-impl-id database) | |
38 (%drop-db-fun-get-impl-name database)) | |
39 | |
40 (defun %create-db-fun-get-impl-id (database) | |
41 (clsql:execute-command " | |
42 CREATE FUNCTION get_impl_id ( | |
43 impl_name VARCHAR(255)) | |
44 RETURNS SMALLINT | |
45 RETURN (SELECT implementation_id | |
46 FROM amuse_implementations | |
47 WHERE implementation_name = impl_name);" | |
48 :database database)) | |
49 | |
50 (defun %drop-db-fun-get-impl-id (database) | |
51 (clsql:execute-command " | |
52 DROP FUNCTION get_impl_id" | |
53 :database database)) | |
54 | |
55 (defun %create-db-fun-get-impl-name (database) | |
56 (clsql:execute-command " | |
57 CREATE FUNCTION get_impl_name ( | |
58 impl_id SMALLINT) | |
59 RETURNS VARCHAR(255) | |
60 RETURN (SELECT implementation_name | |
61 FROM amuse_implementations | |
62 WHERE implementation_id = impl_id);" | |
63 :database database)) | |
64 | |
65 (defun %drop-db-fun-get-impl-name (database) | |
66 (clsql:execute-command " | |
67 DROP FUNCTION get_impl_name" | |
68 :database database)) |