Skip to content

Instantly share code, notes, and snippets.

@mike-burns
Created December 10, 2010 19:23
Show Gist options
  • Save mike-burns/736659 to your computer and use it in GitHub Desktop.
Save mike-burns/736659 to your computer and use it in GitHub Desktop.
Make a Rails migration file ASAP
#!/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