Class: Hist::DbGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hist::DbGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/hist/db_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
14 15 16 17 18 19 20 21 |
# File 'lib/generators/hist/db_generator.rb', line 14 def self.next_migration_number(dirname) #:nodoc: next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
Instance Method Details
#copy_migration ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/generators/hist/db_generator.rb', line 23 def copy_migration [ "create_hist_versions", "create_hist_pendings" ].each do |name| migration_template "db/#{name}.rb.erb", "db/migrate/#{name}.rb", migration_version: migration_version if Dir.glob("db/migrate/*_#{name}.rb").empty? end end |
#migration_version ⇒ Object
32 33 34 35 36 |
# File 'lib/generators/hist/db_generator.rb', line 32 def migration_version if ActiveRecord::VERSION::MAJOR >= 5 "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end end |