cardinal

Migrate

Bring a site's schema and data up to date after an update.

A migrate runs pending platform migrations, then syncs each installed app in order. It is safe to run any time. A migrate over unchanged apps writes nothing.

cardinal migrate -t erp.localhost   # one site
cardinal migrate -t all             # every active site

cardinal start migrates every active site before it serves them. In production, the migrate service runs CardinalCore.Release.migrate() before the nodes start.

What one app's sync does

Takes the site's migration lock. Two migrates on one site run one after the other.

Compares each RecType with its table and applies the difference: new tables, new columns, wider column types.

Upserts the app's fixture Records, only for fixture files that changed since the last sync.

Runs the app's after_install hook the first time, and after_migrate every time.

Each app runs in its own transaction. If one app fails, only its changes roll back.

Columns are never dropped

A field removed from a RecType keeps its column and data. List the leftovers with:

cardinal schema orphans -t erp.localhost

A field's type can widen to a type that holds every old value, such as Int to Data. A migrate refuses a narrowing change, such as Data to Int, and names the column.

Updating apps and Cardinal

TaskCommand
Pull every app in apps/, build and migrate every sitecardinal update
Only one of those stepscardinal update --pull, --build or --migrate
Update the Cardinal checkoutcardinal self-update, then cardinal start

cardinal update skips an app that is linked, pinned to a tag, has uncommitted changes or has no upstream, and says why.

Uninstalling an app

cardinal app uninstall -t HOST APP renames the app's tables instead of dropping them, so the data stays in the schema.

On this page