module EnumGeneratorHelpers::MigrationNumber
Helper methods to figure out the migration number.
Public Instance Methods
next_migration_number(dirname)
click to toggle source
Returns the next upcoming migration number. Sadly, Rails has no API for this, so we’re reduced to copying from ActiveRecord::Generators::Migration @return [Integer]
# File lib/generators/enum/enum_generator_helpers/migration_number.rb, line 8 def next_migration_number(dirname) # Lifted directly from ActiveRecord::Generators::Migration # Unfortunately, no API is provided by Rails at this time. next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base.timestamped_migrations [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end