Class: CurationConcerns::Models::AbstractMigrationGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CurationConcerns::Models::AbstractMigrationGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/curation_concerns/models/abstract_migration_generator.rb
Direct Known Subclasses
Class Method Summary collapse
-
.next_migration_number(path) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Class Method Details
.next_migration_number(path) ⇒ Object
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/generators/curation_concerns/models/abstract_migration_generator.rb', line 10 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 |