class Sufia::Models::AbstractMigrationGenerator
Public Class Methods
next_migration_number(path)
click to toggle source
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
# File lib/generators/sufia/models/abstract_migration_generator.rb, line 9 def self.next_migration_number(path) if @prev_migration_nr @prev_migration_nr += 1 else last_migration = Dir[File.join(path, '*.rb')].sort.last @prev_migration_nr = if last_migration last_migration.sub(File.join(path, '/'), '').to_i + 1 else Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end end @prev_migration_nr.to_s end
Protected Instance Methods
better_migration_template(file)
click to toggle source
# File lib/generators/sufia/models/abstract_migration_generator.rb, line 25 def better_migration_template(file) migration_template "migrations/#{file}", "db/migrate/#{file}" rescue Rails::Generators::Error => e say_status("error", e.message, :red) end