I solved this by creating a new directory in the root of my project called .ebextensions . In this directory, I created the script file my-scripts.config :
.ebextensions/ my-scripts.config app/ artisan bootstrap ...
The my-scripts.config runs when you deploy EBS, is a YAML file, and looks like this:
container_commands: 01-migration: command: "php /var/app/ondeck/artisan --env=staging migrate" leader_only: true
Add the directory and file to git, commit and run git aws.push and it will migrate.
An explanation of how the material works in .ebextensions can be found here .
The path /var/app/ondeck is where your application runs when the script starts, after which it will be copied to /var/app/current .
The artisan --env=staging option is useful for telling the artisan what environment he should work in so that he can find the correct database settings from app/config/staging/database.php
If you need a quick and dirty way to register the cause of the failure, you can try something like "php /var/app/ondeck/artisan --env=staging migrate > /tmp/artisan-migrate.log" so you can log in your ec2 instance and check the log.
source share