Module: ActiveRecord::ConnectionAdapters::Rails81AdapterBehavior
- Included in:
- Rails81Mysql2Adapter, Rails81TrilogyAdapter
- Defined in:
- lib/active_record/connection_adapters/rails_8_1_adapter_behavior.rb
Defined Under Namespace
Modules: ClassMethods Classes: SchemaCreation
Class Method Summary collapse
Instance Method Summary collapse
-
#add_index(table_name, column_name, options = {}) ⇒ Object
add_index is modified from the underlying mysql adapter implementation to ensure we add ALTER TABLE to it.
-
#remove_index(table_name, column_name = nil, **options) ⇒ Object
remove_index is modified from the underlying mysql adapter implementation to ensure we add ALTER TABLE to it.
- #schema_creation ⇒ Object
Class Method Details
.included(adapter_class) ⇒ Object
17 18 19 20 21 |
# File 'lib/active_record/connection_adapters/rails_8_1_adapter_behavior.rb', line 17 def self.included(adapter_class) adapter_class.const_set(:SchemaCreation, SchemaCreation) adapter_class.extend(ClassMethods) adapter_class.include ForAlterStatements unless adapter_class.method_defined?(:change_column_for_alter) end |
Instance Method Details
#add_index(table_name, column_name, options = {}) ⇒ Object
add_index is modified from the underlying mysql adapter implementation to ensure we add ALTER TABLE to it
32 33 34 35 36 37 38 |
# File 'lib/active_record/connection_adapters/rails_8_1_adapter_behavior.rb', line 32 def add_index(table_name, column_name, = {}) index_definition, = (table_name, column_name, **) execute <<-SQL.squish ALTER TABLE #{quote_table_name(index_definition.table)} ADD #{schema_creation.accept(index_definition)} SQL end |
#remove_index(table_name, column_name = nil, **options) ⇒ Object
remove_index is modified from the underlying mysql adapter implementation to ensure we add ALTER TABLE to it
41 42 43 44 45 46 47 |
# File 'lib/active_record/connection_adapters/rails_8_1_adapter_behavior.rb', line 41 def remove_index(table_name, column_name = nil, **) return if [:if_exists] && !index_exists?(table_name, column_name, **) index_name = index_name_for_remove(table_name, column_name, ) execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}" end |
#schema_creation ⇒ Object
49 50 51 |
# File 'lib/active_record/connection_adapters/rails_8_1_adapter_behavior.rb', line 49 def schema_creation self.class::SchemaCreation.new(self) end |