Run migrations at each deploy
Ferry has no pre-deploy command. There are two ways to run a migration at each deploy.
Way 1: a job runs the migration after the deploy is live.
1 / 2
Way 1: a job after each deploy
ferry up notes --follow && ferry run notes --follow -- npm run migrateFor 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 job runs only on the image that is now live.
Way 2: a migration when the app starts
ferry update notes --start-cmd 'npm run migrate && npm start'Each instance runs the migration 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.