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
Instance Method Details
#add_reference(**options) ⇒ Object Also known as: add_belongs_to
115 116 117 118 |
# File 'lib/active_record/migration/compatibility.rb', line 115 def add_reference(*, **) [:index] ||= false super end |
#add_timestamps(_, **options) ⇒ Object
121 122 123 124 |
# File 'lib/active_record/migration/compatibility.rb', line 121 def (_, **) [:null] = true if [:null].nil? super end |
#change_table(table_name, options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/active_record/migration/compatibility.rb', line 102 def change_table(table_name, = {}) if block_given? super(table_name, ) do |t| class << t prepend TableDefinition end yield t end else super end end |
#create_table(table_name, options = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/active_record/migration/compatibility.rb', line 89 def create_table(table_name, = {}) if block_given? super(table_name, ) do |t| class << t prepend TableDefinition end yield t end else super end end |
#index_exists?(table_name, column_name, options = {}) ⇒ Boolean
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/active_record/migration/compatibility.rb', line 126 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
137 138 139 140 141 |
# File 'lib/active_record/migration/compatibility.rb', line 137 def remove_index(table_name, = {}) = { column: } unless .is_a?(Hash) [:name] = index_name_for_remove(table_name, ) super(table_name, ) end |