Skip to content

Commit

Permalink
Fix resume from init with missing migrations file
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Dec 1, 2024
1 parent 42363ff commit 0af0c58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/duct/migrator/ragtime.clj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
migs (load-migrations options)]
(ragtime/migrate-all db index migs {:reporter rep, :strategy strat})
(ragtime/into-index index migs))
(report-missing-migrations-file options)))
(do (report-missing-migrations-file options) {})))

(defmethod ig/init-key :duct.migrator/ragtime [_ options]
(migrate {} options))
Expand Down
2 changes: 1 addition & 1 deletion test/duct/migrator/migrations3.edn
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[[:create-table foo (id "INTEGER")]]
[[:create-table foo (id "INTEGER")]]
11 changes: 10 additions & 1 deletion test/duct/migrator/ragtime_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,14 @@
(is (= [[:duct.migrator.ragtime/missing-file {:path path}]]
@logs))))

(.delete tempfile)))
(testing "resume after missing migration file"
(let [system (swap! system (fn [sys] (ig/suspend! sys) (ig/resume config sys)))
logs (-> system ::logger :logs)
db (-> system :duct.database/sql)]
(is (= ["ragtime_migrations" "foo" "bar"]
(map :sqlite_master/name (find-tables db))))
(is (= [[:duct.migrator.ragtime/applying {:id "create-table-bar#3e718b28"}]]
@logs))))

(ig/halt! @system)
(.delete tempfile)))

0 comments on commit 0af0c58

Please sign in to comment.