integral icon indicating copy to clipboard operation
integral copied to clipboard

redefinition with removing :keys doesn't drop index

Open rudolph-miller opened this issue 9 years ago • 0 comments

At first, I created table and migrate it.

(defclass tweet ()
  ((id :type bigint
        :auto-increment t
        :primary-key t
        :reader tweet-id)
   (user :type (varchar 255)
            :accessor tweet-user))
  (:metaclass <dao-table-class>)
  (:table-name "tweets")
  (:keys user))

(execute-sql (table-definition 'tweet)

then, I redefined this table to

(defclass tweet ()
  ((id :type bigint
        :auto-increment t
        :primary-key t
        :reader tweet-id)
   (user :type (varchar 255)
            :accessor tweet-user))
  (:metaclass <dao-table-class>)
  (:table-name "tweets"))

and

(make-migration-sql (find-class 'tweet))
;; => NIL

.

I can remove index with giving nothing to :keys

(defclass tweet ()
  ((id :type bigint
        :auto-increment t
        :primary-key t
        :reader tweet-id)
   (user :type (varchar 255)
            :accessor tweet-user))
  (:metaclass <dao-table-class>)
  (:table-name "tweets")
  (:keys))

(make-migration-sql (find-class 'tweet))
;; => ("DROP INDEX user ON tweets")

Is this as you expected?

rudolph-miller avatar Mar 11 '15 17:03 rudolph-miller