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.
#!/bin/bash
# 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)
VERSIONS=()
for p in ${INPUT}
do
VERSIONS+=(`ls "db/migrate/${p}"*`)
done
$EDITOR ${VERSIONS[@]}
Written by Minkihn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#