Ben Borgers / Posts /

How to run migrations automatically on Laravel Vapor

January 24, 2021 by @benborgers

You can't run database migrations manually when a Laravel app is in production. Instead, define a deploy hook in vapor.yml:

# Not a full vapor.yml configuration

environments:
  production:
    deploy:
      - 'php artisan migrate --force'

The --force flag confirms that you're okay with running destructive migrations, such as deleting a column.

Vapor will run this command before the deployment is finalized, making any necessary changes to the production database.

A quick favor: was anything I wrote incorrect or misspelled, or do you still have questions? Please use this form to let me know or ask for help!

Loading...