-
-
Save mike-burns/736659 to your computer and use it in GitHub Desktop.
Make a Rails migration file ASAP
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
#!/bin/sh | |
# make a migration file quickly | |
if [ "x$1" = "x" ]; then | |
echo "Usage: mig migration_name" | |
exit | |
else | |
migration_file_name="db/migrate/`date +%Y%m%d%H%M%S`_$1.rb" | |
class_name=`echo $1 | sed -e 's/_\(.\)/\U\1/g' -e 's/./\U&/'` | |
echo "\t\033[32;1mcreate\033[0m\t$migration_file_name" | |
cat <<HERE > $migration_file_name | |
class $class_name < ActiveRecord::Migration | |
def self.up | |
end | |
def self.down | |
end | |
end | |
HERE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment