Merge branch 'master' of github.com:michaelklishin/monger

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
Michael Klishin 2013-07-06 04:38:56 +04:00
commit 78c9336ad7
4 changed files with 31 additions and 8 deletions

View file

@ -16,7 +16,7 @@ Erik Bakstad contributed most of this work.
MongoDB Java driver dependency has been [updated to 2.11.2](https://github.com/mongodb/mongo-java-driver/wiki/Release-Notes).
## monger.core/drop-db
### monger.core/drop-db
`monger.core/drop-db` is a new function that drops a database by name.
@ -36,6 +36,12 @@ implementation that can use any database:
(comment "This cache instance will use the altcache DB"))
```
### Ragtime changes
Bug fix: `monger.ragtime/applied-migration-ids` now returns a vector (instead of a set) in order to preserve the original creation order of the migrations.
Ragtime dependency has been updated to 0.3.3.
## Changes between 1.4.0 and 1.5.0

View file

@ -7,7 +7,7 @@
[org.mongodb/mongo-java-driver "2.11.2"]
[com.novemberain/validateur "1.4.0"]
[clojurewerkz/support "0.15.0"]
[ragtime/ragtime.core "0.3.2"]]
[ragtime/ragtime.core "0.3.3"]]
:test-selectors {:default (fn [m]
(and (not (:performance m))
(not (:edge-features m))

View file

@ -24,11 +24,11 @@
(let [xs (with-collection migrations-collection
(find {})
(sort {:created_at 1}))]
(set (map :_id xs))))))
(vec (map :_id xs))))))
(defn flush-migrations!
"REMOVES all the information about previously performed migrations"
[db]
(mg/with-db db
(mc/remove migrations-collection)))
(mc/remove migrations-collection)))

View file

@ -22,10 +22,10 @@
key "1"]
(mc/remove db coll {})
(is (not (mc/any? db coll {:_id key})))
(is (not (contains? (applied-migration-ids db) key)))
(is (not (some #{key} (applied-migration-ids db))))
(add-migration-id db key)
(is (mc/any? db coll {:_id key}))
(is (contains? (applied-migration-ids db) key))))
(is (some #{key} (applied-migration-ids db)))))
(deftest test-remove-migration-id
@ -35,6 +35,23 @@
(mc/remove db coll {})
(add-migration-id db key)
(is (mc/any? db coll {:_id key}))
(is (contains? (applied-migration-ids db) key))
(is (some #{key} (applied-migration-ids db)))
(remove-migration-id db key)
(is (not (contains? (applied-migration-ids db) key))))))
(is (not (some #{key} (applied-migration-ids db))))))
(deftest test-migrations-ordering
(let [db (mg/get-db "monger-test")
coll "meta.migrations"
all-keys [ "9" "4" "7" "1" "5" "3" "6" "2" "8"]]
(mc/remove db coll {})
(doseq [key all-keys]
(add-migration-id db key))
(doseq [key all-keys]
(is (mc/any? db coll {:_id key}))
(is (some #{key} (applied-migration-ids db))))
(testing "Applied migrations must come out in creation order"
(is (= all-keys (applied-migration-ids db)))))))