FerryDocs

Run migrations at each deploy

Ferry has no pre-deploy command. There are two ways to run a migration at each deploy.

Edit on GitHub
DeployJobnpm run migrateEach instancemigrate then startnotes-db

Way 1: a job runs the migration after the deploy is live.

1 / 2

Way 1: a job after each deploy

Terminal
ferry up notes --follow && ferry run notes --follow -- npm run migrate

For a service that deploys from git, use ferry deploy notes --follow as the first command.

With --follow, the first command fails if the deploy fails. Thus the runs only on the that is now live.

Way 2: a migration when the app starts

Terminal
ferry update notes --start-cmd 'npm run migrate && npm start'

Each runs the when it starts. Thus the migration must be safe to run more than one time, and at the same time.

Use CREATE TABLE IF NOT EXISTS, or a migration tool that takes a lock.

On this page