Class: Gutentag::Generators::MigrationVersionsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/gutentag/generators/migration_versions_generator.rb

Instance Method Summary collapse

Instance Method Details

#update_migration_versionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gutentag/generators/migration_versions_generator.rb', line 10

def update_migration_versions
  superclass = "ActiveRecord::Migration[#{rails_version}]"

  if ::ActiveRecord::VERSION::MAJOR < 5
    superclass = "ActiveRecord::Migration"
  end

  migration_files.each do |file|
    gsub_file file,
      /< ActiveRecord::Migration\[4\.2\]$/,
      "< #{superclass}"
  end
end