r9108: support multiple creation of indices
[umlisp.git] / create-sql.lisp
index ec162b84c3c6ada4e50a491514b84b7686d5dfec..66b9c028c8cfd1c1023dba59cb66bfd75da97ad2 100644 (file)
@@ -2,15 +2,15 @@
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
-;;;; Name:          sql-create
-;;;; Purpose:       Create SQL database for UMLisp
-;;;; Author:        Kevin M. Rosenberg
-;;;; Date Started:  Apr 2000
+;;;; Name:     sql-create
+;;;; Purpose:  Create SQL database for UMLisp
+;;;; Author:   Kevin M. Rosenberg
+;;;; Created:  Apr 2000
 ;;;;
 ;;;; $Id$
 ;;;;
 ;;;; This file, part of UMLisp, is
-;;;;    Copyright (c) 2000-2003 by Kevin M. Rosenberg, M.D.
+;;;;    Copyright (c) 2000-2004 by Kevin M. Rosenberg, M.D.
 ;;;;
 ;;;; UMLisp users are granted the rights to distribute and use this software
 ;;;; as governed by the terms of the GNU General Public License.
   (dolist (file *umls-files*)
     (sql-insert-values conn file)))
 
+(defun drop-index-cmd (colname tablename)
+  "Return sql create index command"
+  (case *umls-sql-type
+    (:mysql
+     (format nil "DROP INDEX ~a ON ~a"
+            (concatenate 'string tablename "_" colname "_X")
+            tablename))
+    (t
+     (format nil "DROP INDEX ~a"
+            (concatenate 'string tablename "_" colname "_X")))))
+
 (defun sql-create-indexes (conn &optional (indexes +index-cols+))
   "SQL Databases: create all indexes"
   (dolist (idx indexes)
+    (ignore-errors
+     (sql-execute (drop-index-cmd (car idx) (cadr idx)) conn))
     (sql-execute (create-index-cmd (car idx) (cadr idx) (caddr idx)) conn))) 
 
 (defun make-usrl (conn)