Class: ActiveRecord::ConnectionAdapters::Rails81DepartureAdapter

Inherits:
Mysql2Adapter
  • Object
show all
Extended by:
Forwardable
Includes:
ForAlterStatements
Defined in:
lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb

Defined Under Namespace

Classes: Column, SchemaCreation

Constant Summary collapse

TYPE_MAP =
Type::TypeMap.new.tap { |m| initialize_type_map(m) }
ADAPTER_NAME =
'Percona'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ForAlterStatements

#add_column_for_alter, #add_index_for_alter, #add_timestamps_for_alter, #bulk_change_table, #change_column_for_alter, included, #remove_column_for_alter, #remove_columns_for_alter, #remove_index_for_alter, #remove_timestamps_for_alter, #rename_column_for_alter

Class Method Details

.new_client(config) ⇒ Object



42
43
44
45
46
# File 'lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb', line 42

def self.new_client(config)
  original_client = super

  Departure::DbClient.new(config, original_client)
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



49
50
51
52
53
54
55
# File 'lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb', line 49

def add_index(table_name, column_name, options = {})
  index_definition, = add_index_options(table_name, column_name, **options)
  execute "    ALTER TABLE \#{quote_table_name(index_definition.table)}\n      ADD \#{schema_creation.accept(index_definition)}\n  SQL\nend\n".squish

#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



58
59
60
61
62
63
64
# File 'lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb', line 58

def remove_index(table_name, column_name = nil, **options)
  return if options[:if_exists] && !index_exists?(table_name, column_name, **options)

  index_name = index_name_for_remove(table_name, column_name, options)

  execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}"
end

#schema_creationObject



66
67
68
# File 'lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb', line 66

def schema_creation
  SchemaCreation.new(self)
end