Class: ActiveRecordDoctor::AddIndexesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActiveRecordDoctor::AddIndexesGenerator
- Defined in:
- lib/generators/active_record_doctor/add_indexes/add_indexes_generator.rb
Overview
Generate migrations that add missing indexes to the database.
Instance Method Summary collapse
Instance Method Details
#create_migrations ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/generators/active_record_doctor/add_indexes/add_indexes_generator.rb', line 9 def create_migrations migration_descriptions = read_migration_descriptions(path) now = Time.now migration_descriptions.each_with_index do |(table, indexes), index| = (now + index).strftime("%Y%m%d%H%M%S") file_name = "db/migrate/#{}_index_foreign_keys_in_#{table}.rb" create_file(file_name, content(table, indexes).tap { |x| puts x }) end end |