123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::Generators::Migration

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Defined in: activerecord/lib/rails/generators/active_record/migration.rb

Class Method Summary

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

append_features, prepend_features

Instance Attribute Summary

Instance Method Summary

Instance Method Details

#configured_migrate_path (private)

[ GitHub ]

  
# File 'activerecord/lib/rails/generators/active_record/migration.rb', line 42

def configured_migrate_path
  return unless database = options[:database]

  config = ActiveRecord::Base.configurations.configs_for(
    env_name: Rails.env,
    name: database
  )

  Array(config&.migrations_paths).first
end

#db_migrate_path (private)

[ GitHub ]

  
# File 'activerecord/lib/rails/generators/active_record/migration.rb', line 30

def db_migrate_path
  if defined?(Rails.application) && Rails.application
    configured_migrate_path || default_migrate_path
  else
    "db/migrate"
  end
end

#default_migrate_path (private)

[ GitHub ]

  
# File 'activerecord/lib/rails/generators/active_record/migration.rb', line 38

def default_migrate_path
  Rails.application.config.paths["db/migrate"].to_ary.first
end

#foreign_key_type (private)

[ GitHub ]

  
# File 'activerecord/lib/rails/generators/active_record/migration.rb', line 25

def foreign_key_type
  key_type = options[:primary_key_type]
  ", type: :#{key_type}" if key_type
end

#primary_key_type (private)

[ GitHub ]

  
# File 'activerecord/lib/rails/generators/active_record/migration.rb', line 20

def primary_key_type
  key_type = options[:primary_key_type]
  ", id: :#{key_type}" if key_type
end