Class: GarlandRails::UninstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/garland_rails/uninstall_generator.rb

Overview

TODO: DRY

Constant Summary collapse

@@migrations =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

:nodoc:



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/garland_rails/uninstall_generator.rb', line 16

def self.next_migration_number(dirname) #:nodoc:
  if ActiveRecord::Base.timestamped_migrations
    if @@migrations
      (current_migration_number(dirname) + 1)
    else
      @@migrations = true
      Time.now.utc.strftime('%Y%m%d%H%M%S')
    end
  else
    format '%.3d', current_migration_number(dirname) + 1
  end
end

Instance Method Details

#create_migration_fileObject



29
30
31
32
33
# File 'lib/generators/garland_rails/uninstall_generator.rb', line 29

def create_migration_file
  source = "uninstall_migration.rb"
  destination = "db/migrate/uninstall_garland.rb"
  migration_template source, destination
end