diff --git a/jdbc/src/ragtime/jdbc.clj b/jdbc/src/ragtime/jdbc.clj index e8139ff..4a2f59f 100644 --- a/jdbc/src/ragtime/jdbc.clj +++ b/jdbc/src/ragtime/jdbc.clj @@ -128,7 +128,7 @@ (rest (re-matches #"(.*?)\.(up|down)(?:\.(\d+))?\.sql" (str file)))) (defn- read-sql [file] - (str/split (slurp file) #"(?m)\n\s*--;;\s*\n")) + (str/split (slurp file) #"(?m)\n\s*--\s?;;\s*\n")) (defmethod load-files ".sql" [files] (for [[id files] (->> files diff --git a/jdbc/test/migrations/007-test.down.sql b/jdbc/test/migrations/007-test.down.sql new file mode 100644 index 0000000..1876ab9 --- /dev/null +++ b/jdbc/test/migrations/007-test.down.sql @@ -0,0 +1,6 @@ +-- +-- ISSUE 159 Test +-- +DROP TABLE quxc; +-- ;; +DROP TABLE quxd; diff --git a/jdbc/test/migrations/007-test.up.sql b/jdbc/test/migrations/007-test.up.sql new file mode 100644 index 0000000..8fcb324 --- /dev/null +++ b/jdbc/test/migrations/007-test.up.sql @@ -0,0 +1,6 @@ +-- +-- ISSUE 159 Test +-- +CREATE TABLE quxc (id int); +-- ;; +CREATE TABLE quxd (id int); diff --git a/jdbc/test/ragtime/jdbc_test.clj b/jdbc/test/ragtime/jdbc_test.clj index ac37798..b373210 100644 --- a/jdbc/test/ragtime/jdbc_test.clj +++ b/jdbc/test/ragtime/jdbc_test.clj @@ -77,9 +77,9 @@ ms (jdbc/load-directory "test/migrations") idx (core/into-index ms)] (core/migrate-all db idx ms) - (is (= #{"RAGTIME_MIGRATIONS" "FOO" "BAR" "BAZ" "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE"} + (is (= #{"RAGTIME_MIGRATIONS" "FOO" "BAR" "BAZ" "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE" "QUXC" "QUXD"} (table-names db))) - (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test"] + (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test" "007-test"] (p/applied-migration-ids db))) (core/rollback-last db idx (count ms)) (is (= #{"RAGTIME_MIGRATIONS"} (table-names db))) @@ -90,9 +90,9 @@ ms (jdbc/load-resources "migrations") idx (core/into-index ms)] (core/migrate-all db idx ms) - (is (= #{"RAGTIME_MIGRATIONS" "FOO" "BAR" "BAZ" "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE"} + (is (= #{"RAGTIME_MIGRATIONS" "FOO" "BAR" "BAZ" "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE" "QUXC" "QUXD"} (table-names db))) - (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test"] + (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test" "007-test"] (p/applied-migration-ids db))) (core/rollback-last db idx (count ms)) (is (= #{"RAGTIME_MIGRATIONS"} (table-names db))) diff --git a/next-jdbc/src/ragtime/next_jdbc.clj b/next-jdbc/src/ragtime/next_jdbc.clj index 4aff771..5ab6b66 100644 --- a/next-jdbc/src/ragtime/next_jdbc.clj +++ b/next-jdbc/src/ragtime/next_jdbc.clj @@ -163,7 +163,7 @@ (rest (re-matches #"(.*?)\.(up|down)(?:\.(\d+))?\.sql" (str file)))) (defn- read-sql [file] - (str/split (slurp file) #"(?m)\n\s*--;;\s*\n")) + (str/split (slurp file) #"(?m)\n\s*--\s?;;\s*\n")) (defmethod load-files ".sql" [files] (for [[id files] (->> files diff --git a/next-jdbc/test/migrations/007-test.down.sql b/next-jdbc/test/migrations/007-test.down.sql new file mode 100644 index 0000000..1876ab9 --- /dev/null +++ b/next-jdbc/test/migrations/007-test.down.sql @@ -0,0 +1,6 @@ +-- +-- ISSUE 159 Test +-- +DROP TABLE quxc; +-- ;; +DROP TABLE quxd; diff --git a/next-jdbc/test/migrations/007-test.up.sql b/next-jdbc/test/migrations/007-test.up.sql new file mode 100644 index 0000000..8fcb324 --- /dev/null +++ b/next-jdbc/test/migrations/007-test.up.sql @@ -0,0 +1,6 @@ +-- +-- ISSUE 159 Test +-- +CREATE TABLE quxc (id int); +-- ;; +CREATE TABLE quxd (id int); diff --git a/next-jdbc/test/ragtime/next_jdbc_test.clj b/next-jdbc/test/ragtime/next_jdbc_test.clj index f7744fa..3c790a3 100644 --- a/next-jdbc/test/ragtime/next_jdbc_test.clj +++ b/next-jdbc/test/ragtime/next_jdbc_test.clj @@ -94,9 +94,9 @@ idx (core/into-index ms)] (core/migrate-all db idx ms) (is (= #{"RAGTIME_MIGRATIONS" "FOO" "BAR" "BAZ" - "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE"} + "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE" "QUXC" "QUXD"} (table-names db))) - (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test"] + (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test" "007-test"] (p/applied-migration-ids db))) (core/rollback-last db idx (count ms)) (is (= #{"RAGTIME_MIGRATIONS"} (table-names db))) @@ -108,9 +108,9 @@ idx (core/into-index ms)] (core/migrate-all db idx ms) (is (= #{"RAGTIME_MIGRATIONS" "FOO" "BAR" "BAZ" - "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE"} + "QUZA" "QUZB" "QUXA" "QUXB" "LAST_TABLE" "QUXC" "QUXD"} (table-names db))) - (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test"] + (is (= ["001-test" "002-bar" "003-test" "004-test" "005-test" "006-test" "007-test"] (p/applied-migration-ids db))) (core/rollback-last db idx (count ms)) (is (= #{"RAGTIME_MIGRATIONS"} (table-names db)))