Creating the Migration File and Helper Scripts

Learn to create migration file and helper scripts for our Rails application.

We'll cover the following

Helper script

Before we create the migration file, we need three scripts to help this process. We find that bin/rails db:migrate and bin/rails db:rollback don’t consistently modify both the development and test schema. This can result in a test schema that is not the same as what’s described in the migration file, which can cause some confusing test behavior. Rather than document this problem, let’s make two scripts to handle applying migrations and rolling them back.

Here’s the script to migrate all databases:

Get hands-on with 1200+ tech skills courses.