bundle exec rake db:migrate
to execute them.
To automatically run migrations on each deploy to Aptible, you can use a before_release
command.
To do so, add the following to your .aptible.yml
file (adjust the command as needed depending on your framework):
❗️ Don’t break your App when running Database migrations! It’s easy to forget that your App will be running when automated Database migrations execute, but it’s important not to. For example, if your migration locks a table for 10 minutes (e.g., to create a new index synchronously), then that table is going to read-only for 10 minutes. If your App needs to write to this table to function, it will be down. Also, if your App is a web App, review the docs over here: Concurrent Releases.
if
branches, etc.), we recommend encapsulating this logic in a separate script:
❗️The script needs to be made executable. To do so, run chmod script/before_release.sh
.
Your new .aptible.yml
would read: