Class: RailsMfa::Generators::MigrationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/rails_mfa/migration_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



18
19
20
# File 'lib/generators/rails_mfa/migration_generator.rb', line 18

def self.next_migration_number(dirname)
  ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#create_migration_fileObject



22
23
24
25
26
27
# File 'lib/generators/rails_mfa/migration_generator.rb', line 22

def create_migration_file
  migration_template(
    "migration.rb.erb",
    "db/migrate/add_mfa_to_#{table_name}.rb"
  )
end

#show_instructionsObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/rails_mfa/migration_generator.rb', line 29

def show_instructions
  return unless behavior == :invoke

  say ""
  say "Migration created!", :green
  say ""
  say "Next steps:", :yellow
  say "  1. Review the migration file"
  say "  2. Run: rails db:migrate"
  say "  3. Include RailsMFA::Model in your #{class_name} model"
  say ""
end