Skip to content

Add Auto-Migrate to VMS#235

Open
rjsheperd wants to merge 2 commits into
rj-add-calculator-validationsfrom
rj-auto-migrate
Open

Add Auto-Migrate to VMS#235
rjsheperd wants to merge 2 commits into
rj-add-calculator-validationsfrom
rj-auto-migrate

Conversation

@rjsheperd
Copy link
Copy Markdown
Contributor

Purpose

Auto-run Datomic migrations on VMS startup.

  • behave-cms.server/init-db! now calls schema-migrate.runner/run-pending-migrations! after schema sync.
  • Files in development/migrations/ are picked up by name, skipped if marked :migrate/ignore? true or already recorded via :bp/migration-id.
  • Existing migrations are marked ignored.

New Migrations Pattern

(ns migrations.2026-05-19-example
  (:require [datomic.api :as d]))

(defn payload-fn [conn]
  [[:db/add (d/q '[:find ?e . :in $ ?tk
                   :where [?e :group/translation-key ?tk]]
                 (d/db conn) "behaveplus:...")
    :group/order 0]])

For more info, check out the development/migrations/README.org , and check out development/migrations/template.clj for the template that can be re-used.

Testing

  1. Run the following:
  cd components/schema_migrate
  clojure -M:test -e "(require 'schema-migrate.runner-test) (clojure.test/run-tests 'schema-migrate.runner-test)"

Should show Expect Ran 8 tests containing 19 assertions. 0 failures, 0 errors.
2. Start the VMS. The console should print "Running migration: … / Applied: …" for any new migrations.
3. Restart the VMS, and verify that the migrations are skipped on restart.

@rjsheperd rjsheperd changed the title Rj auto migrate Add Auto-Migrate to VMS May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant