Sha256: 8d715ab0441cb332b712b32d29e43b7db1cba076d6f212418dfa04b1608cf73d
Contents?: true
Size: 543 Bytes
Versions: 8
Compression:
Stored size: 543 Bytes
Contents
class MigrationGenerator < RubiGen::NamedBase def manifest record do |m| m.migration_template 'migration.rb', 'db/migrate' end end def auto_migration direction case class_name.underscore when /^(add|remove)_(.*)_(?:to|from)_(.*)/ then action, col, tbl = $1, $2, $3.pluralize unless (action == "add") ^ (direction == :up) then %(\n add_column :#{tbl}, :#{col}, :type, :null => :no?, :default => :maybe?) else %(\n remove_column :#{tbl}, :#{col}) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems