Last Updated: May 03, 2017
· Minkihn

Open pending Rails migrations in your text editor (Example)

When I checkout a new branch from a teammate, I find it a bit tedious to have to guess or list pending migrations manually. Here's a script I use regularly, grepping rake db:migrate:status and cutting the output to retrieve corresponding timestamps with ls. Voila, everything opened in SublimeText.


# Open all your pending Rails migrations into your text editor.
# It's not optimal but should work with gnu and bsd tools.
# Author: Maxime Buffa <mbuffa@gmail.com>

INPUT=$(rake db:migrate:status|grep -e '^  down    '|cut -c 11-24)

for p in ${INPUT}
  VERSIONS+=(`ls "db/migrate/${p}"*`)
Say Thanks