Sha256: 88d1f768638bffbf0b4aaf2aa7af9c1c6fb2943a5eb6eee2e4ef76e2e9e0f3cd
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
require 'rails/generators' require 'rails/generators/migration' require 'migration_assist/helper/file_name' module Rails3::Migration::Assist include Rails::Generators::Migration include FileNameHelper def reverse_migration_name name name.gsub(/^add_/, 'remove_').gsub(/^create_/, 'drop_') end def reverse_migration! migration_path reverse_class_names! migration_path reverse_up_down_methods! migration_path end def reverse_class_names! migration_path # Change class name gsub_file migration_path, /class Add/, 'class Remove' gsub_file migration_path, /class Create/, 'class Drop' end def reverse_up_down_methods! migration_path # swap up and down methods gsub_file migration_path, /up/, 'dwn' gsub_file migration_path, /down/, 'up' gsub_file migration_path, /dwn/, 'down' end def latest_migration_file dir, name self.class.latest_migration_file dir, name end def migration name, template_name=nil migration_template "#{template_name || name}.erb", migration_file_name(name) end end
Version data entries
4 entries across 4 versions & 1 rubygems