I want to try to generate migration inside rails console.
This file is responsible for migration creation (particularly create_migrate_file method):
rails/generators/active_record/migration/migration_generator.rb
But, for some reason, in my console I can't call ActiveRecord::Generators::MigrationGenerator class.
NameError: uninitialized constant ActiveRecord::Generators::MigrationGenerator
You need to first require rails/generators
and then the file where ActiveRecord::Generators::MigrationGenerator
is defined.
require 'rails/generators'
require 'rails/generators/active_record/migration/migration_generator'
ActiveRecord::Generators::MigrationGenerator
# => ActiveRecord::Generators::MigrationGenerator