Class: ActiveRecord::Migration::Compatibility::V4_2
- Defined in:
- lib/active_record/migration/compatibility.rb
Defined Under Namespace
Modules: TableDefinition
Instance Method Summary collapse
- #add_reference(**options) ⇒ Object (also: #add_belongs_to)
- #add_timestamps(_, **options) ⇒ Object
- #change_table(table_name, options = {}) ⇒ Object
- #create_table(table_name, options = {}) ⇒ Object
- #index_exists?(table_name, column_name, options = {}) ⇒ Boolean
- #remove_index(table_name, options = {}) ⇒ Object
Methods inherited from V5_0
Instance Method Details
#add_reference(**options) ⇒ Object Also known as: add_belongs_to
123 124 125 126 |
# File 'lib/active_record/migration/compatibility.rb', line 123 def add_reference(*, **) [:index] ||= false super end |
#add_timestamps(_, **options) ⇒ Object
129 130 131 132 |
# File 'lib/active_record/migration/compatibility.rb', line 129 def (_, **) [:null] = true if [:null].nil? super end |
#change_table(table_name, options = {}) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/active_record/migration/compatibility.rb', line 113 def change_table(table_name, = {}) if block_given? super do |t| yield compatible_table_definition(t) end else super end end |
#create_table(table_name, options = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/active_record/migration/compatibility.rb', line 103 def create_table(table_name, = {}) if block_given? super do |t| yield compatible_table_definition(t) end else super end end |
#index_exists?(table_name, column_name, options = {}) ⇒ Boolean
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/active_record/migration/compatibility.rb', line 134 def index_exists?(table_name, column_name, = {}) column_names = Array(column_name).map(&:to_s) [:name] = if [:name].present? [:name].to_s else index_name(table_name, column: column_names) end super end |
#remove_index(table_name, options = {}) ⇒ Object
145 146 147 148 149 |
# File 'lib/active_record/migration/compatibility.rb', line 145 def remove_index(table_name, = {}) = { column: } unless .is_a?(Hash) [:name] = index_name_for_remove(table_name, ) super(table_name, ) end |