Commits

Shantanu Kumar committed 7d2bfc3

remove unwanted `create-table-changeset` and `create-table-withid-changeset` functions

Comments (0)

Files changed (4)

 * Use Clj-DBSpec 0.3
 * Liquibase Functionality (commands)
   # Diff (Regular database diff - output to STDOUT)
-* Idiomatic convenience `make-changeset` variants:
-  # New: `create-table-changeset` to wrap `change/create-table`
-  # New: `create-table-withid-changeset` wrap `change/create-table-withid`
-  # Documented as "Not for external use":
-    * change/create-table
-    * change/create-table-withid
+* `make-changeset` now accepts SQL-visitors as optional argument
 * 'Change' implementations
   # Create table: `create-table-withid` (updated)
     * Allow user to specify ID column name via an optional argument :idcol

src/main/clj/org/bituf/clj_liquibase.clj

     c-set))
 
 
-(defn create-table-changeset-internal
-  "Common internal implementation for `create-table-changeset` and
-  `create-table-withid-changeset`."
-  [f ct-vkeys ^String id ^String author table-name ^List columns
-   & {:keys [dummy] :as opt}]
-  (let [map2vec  (partial reduce into [])
-        ct-vargs (map2vec (select-keys opt ct-vkeys))
-        ;; mc = make-changeset
-        mc-visit (vis/make-visitors
-                   :include (map (partial vis/for-dbms! :mysql)
-                                 (vis/make-visitors :append "engine=InnoDB")))
-        mc-vargs (map2vec (apply dissoc (merge {:visitors mc-visit} opt)
-                                 ct-vkeys))]
-    (apply make-changeset id author
-           [(apply f table-name columns ct-vargs)]
-           mc-vargs)))
-
-
-(defn create-table-changeset
-  "Convenience function to build a changeset for `create-table` change with
-  sensible defaults, e.g. create a table on MySQL with InnoDB storage engine.
-  Optional arguments are a union of those in `make-changeset` and
-  `change/create-table`.
-  See also:
-    make-changeset
-    change/create-table"
-  [^String id ^String author table-name ^List columns & args]
-  (apply create-table-changeset-internal
-         ch/create-table
-         [:schema-name :schema :table-space :tspace :remarks]
-         id author table-name columns args))
-
-
-(defn create-table-withid-changeset
-  "Convenience function to build a changeset for `create-table-withid` with
-  sensible defaults, e.g. create a table on MySQL with InnoDB storage engine.
-  Optional arguments are a union of those in `make-changeset` and
-  `change/create-table-withid`.
-  See also:
-    make-changeset
-    change/create-table-withid"
-  [^String id ^String author table-name ^List columns & args]
-  (apply create-table-changeset-internal
-         ch/create-table-withid
-         [:schema-name :schema :table-space :tspace :remarks :idcol]
-         id author table-name columns args))
-
-
 ;; ===== DatabaseChangeLog helpers =====
 
 
     make-changelog"
   [var-name change-sets & var-args]
   `(def ~var-name
-     (partial make-changelog (or (and *logical-filepath* (mu/java-filepath
-                                                           *logical-filepath*))
+     (partial make-changelog (if *logical-filepath*
+                               (mu/java-filepath *logical-filepath*)
                                (mu/pick-filename *file*))
        ~change-sets ~@var-args)))
 

src/main/clj/org/bituf/clj_liquibase/change.clj

 
 (defn ^CreateTableChange create-table
   "Return a Change instance that creates a table (CreateTableChange).
-  NOTE! : User should call `clj-liquibase/create-table-changeset` instead.
   See also:
     http://www.liquibase.org/manual/create_table
-    http://www.liquibase.org/manual/column
-    clj-liquibase/create-table-changeset"
+    http://www.liquibase.org/manual/column"
   [table-name ^List columns
    & {:keys [schema-name schema ; String/Keyword - subject to db-iden
              table-space tspace ; String/Keyword - subject to db-iden
   key column. The primary key column is named <table-name>_id unless overriden
   with optional argument `:idcol` and ID column-name as the value. E.g. if the
   table name is :sample or \"sample\", then primary key will be \"sample_id\".
-  NOTE! : User should call `clj-liquibase/create-table-withid-changeset` instead.
   See also:
-    create-table
-    clj-liquibase/create-table-withid-changeset"
+    create-table"
   [table-name columns & args]
   (let [{:keys [idcol] :as opt} args
         idcol-name (if idcol

src/test/clj/org/bituf/test_clj_liquibase.clj

                            )) "Optional arguments with shortname"))))
 
 
-(deftest test-create-table-changeset
-  (let [args ["id=1" "author=shantanu" :sample-table
-              [[:first-name [:varchar 40] :null false]
-               [:last-name  [:varchar 40]]
-               [:date-born  :date]]
-              :filepath "dummy"]]
-    (doseq [[f n] [[lb/create-table-changeset        "create-table"]
-                   [lb/create-table-withid-changeset "create-table-withid"]]]
-      (is (lb/changeset? (apply f args))
-          (str n " with no optional arg"))
-      (is (lb/changeset? (apply f (into args [:schema "some"])))
-          (str n " with one optional arg for " n))
-      (is (lb/changeset? (apply f (into args [:always true :in-txn true])))
-          (str n " with 2 optional args for make-changeset")))
-    (is (lb/changeset? (apply lb/create-table-withid-changeset
-                              (into args [:always true :idcol :id])))
-        (format "%s with an optional arg for make-changeset and :idcol for %s"
-                "create-table-withid" "create-table-withid"))))
-
-
 ;; ===== DatabaseChangeLog =====
 
 
 (defn test-ns-hook []
   ;; ===== ChangeSet =====
   (test-make-changeset)
-  (test-create-table-changeset)
   ;; ===== DatabaseChangeLog =====
   (test-make-changelog)
   (test-defchangelog)