Created
October 1, 2012 09:08
-
-
Save jasonm/3810464 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash or zsh function | |
# change self.up to up, self.down to down for Rails 3.1+ | |
rails_migration() { | |
filename="db/migrate/`date +%Y%m%d%H%M%S`_$1.rb" | |
classname=$(ruby -e "puts '$1'.split('_').map{|e| e.capitalize}.join") | |
touch $filename | |
echo "class $classname < ActiveRecord::Migration" >> $filename | |
echo " def self.up" >> $filename | |
echo " end" >> $filename | |
echo "" >> $filename | |
echo " def self.down" >> $filename | |
echo " end" >> $filename | |
echo "end" >> $filename | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment