Class: SeparateHistory::Generators::SyncGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/separate_history/sync/sync_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/separate_history/sync/sync_generator.rb', line 11

def create_migration_file
  @model_class = name.classify.constantize
  @history_table_name = "#{name.underscore}_histories"

  check_for_mismatched_columns

  @missing_columns = find_missing_columns

  if @missing_columns.any?
    migration_template "migration.rb.erb", "db/migrate/sync_#{file_name}_history.rb"
  else
    say_status :skipped, "No new columns to add for #{name}", :green
  end
end