1. Shantanu Kumar
  2. Clj-Liquibase

Commits

Shantanu Kumar  committed c93e2a5

add sql-visitor feature

  • Participants
  • Parent commits c3fc41f
  • Branches default

Comments (0)

Files changed (2)

File CHANGES

View file
  • Ignore whitespace
   # Generate Changelog
 - [TODO] 'Change' implementations:
   # Custom Refactorings
-    * Modifying Generated SQL
     * Custom SQL
     * Custom SQL File
     * Custom Refactoring Class
     * Execute Shell Command
 
 
-## 0.3 / 2011-Jul-??
+## 0.3 / 2011-Nov-??
 
 * Use Clj-DBSpec 0.3
 * Liquibase Functionality (commands)
-  * Diff (Regular database diff - output to STDOUT)
+  # Diff (Regular database diff - output to STDOUT)
+* 'Change' implementations
+  # Custom Refactorings
+    * Modifying Generated SQL (Append, Prepend, Replace SQL visitors)
+    * [TODO] tests for SQL visitors
 * Cleanup implementations
-  * [TODO] (..list them..)
+  # [TODO] `create-table-changeset`; deprecate `create-table` for external use
 
 
 ## 0.2 / 2011-Apr-01

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

View file
  • Ignore whitespace
     (liquibase.precondition            Precondition)
     (liquibase.precondition.core       PreconditionContainer)
     (liquibase.sql                     Sql)
+    (liquibase.sql.visitor             SqlVisitor)
     (liquibase.sqlgenerator            SqlGeneratorFactory)
     (liquibase.statement               SqlStatement)
     (liquibase.util                    LiquibaseUtil))
     [org.bituf.clj-dbspec   :as sp]
     [org.bituf.clj-miscutil :as mu]
     [org.bituf.clj-liquibase.internal     :as in]
-    [org.bituf.clj-liquibase.precondition :as pc]))
+    [org.bituf.clj-liquibase.precondition :as pc]
+    [org.bituf.clj-liquibase.sql-visitor  :as vis]))
 
 
 (def ^{:doc "Clj-Liquibase version (only major and minor)"}
   []
   (when (not (string? *logical-filepath*))
     (throw (IllegalStateException.
-             (format "Expected %s but found %s - not wrapped in 'defchangelog'?"
-               "var *logical-filepath* to be string"
-               (mu/val-dump *logical-filepath*)))))
+             ^String (format
+                       "Expected %s but found %s - not wrapped in 'defchangelog'?"
+                       "var *logical-filepath* to be string"
+                       (mu/val-dump *logical-filepath*)))))
   true)
 
 
     :comment                        ; String
     :pre-conditions     :pre-cond   ; list of Precondition objects, or PreconditionContainer object
     :valid-checksum     :valid-csum ; String
+    :visitors                       ; list of SqlVisitor objects
   See also:
     http://www.liquibase.org/manual/changeset"
   [^String id ^String author ^List changes
              pre-conditions     pre-cond
              rollback-changes   rollback
              valid-checksum     valid-csum
+             visitors
              ] :as opt}] {:post [(instance? ChangeSet %)]
                           :pre  [(mu/verify-opt #{:logical-filepath   :filepath
                                                   :dbms
                                                   :comment
                                                   :pre-conditions     :pre-cond
                                                   :rollback-changes   :rollback
-                                                  :valid-checksum     :valid-csum} opt)
+                                                  :valid-checksum     :valid-csum
+                                                  :visitors} opt)
                                  (mu/verify-arg (string?       id))
                                  (mu/verify-arg (string?       author))
                                  (mu/verify-arg (coll?         changes))
-                                 (mu/verify-arg (mu/not-empty? changes))]}
+                                 (mu/verify-arg (mu/not-empty? changes))
+                                 (mu/verify-arg (every? vis/visitor? visitors))]}
   (when-not (or logical-filepath filepath)
     (verify-valid-logical-filepath))
   (let [s-filepath (or logical-filepath filepath *logical-filepath*)
                        (.addRollbackChange c-set ^Change each))))
     (if s-val-csum (doseq [each (mu/as-vector s-val-csum)]
                      (.addValidCheckSum c-set each)))
+    (doseq [each visitors]
+      (.addSqlVisitor c-set ^SqlVisitor each))
     c-set))