Module: PgPower::ConnectionAdapters::PostgreSQLAdapter::IndexMethods
- Included in:
- PgPower::ConnectionAdapters::PostgreSQLAdapter
- Defined in:
- lib/pg_power/connection_adapters/postgresql_adapter/index_methods.rb
Overview
Provides methods to extend ActiveRecord::ConnectionAdapters::SchemaStatements to support index features.
Instance Method Summary collapse
-
#index_name(table_name, options) ⇒ Object
Overrides ActiveRecord::ConnectionAdapters::SchemaStatements.index_name to support schema notation.
-
#index_name_for_remove(table_name, options = {}) ⇒ Object
Overrides ActiveRecord::ConnectionAdapters::SchemaStatements.index_name_for_remove to support schema notation.
- #supports_partial_index? ⇒ Boolean
Instance Method Details
#index_name(table_name, options) ⇒ Object
Overrides ActiveRecord::ConnectionAdapters::SchemaStatements.index_name to support schema notation. Converts dots in index name to underscores.
Example
add_index 'demography.citizens', :country_id
# produces
CREATE INDEX "index_demography_citizens_on_country_id" ON "demography"."citizens" ("country_id")
# instead of
CREATE INDEX "index_demography.citizens_on_country_id" ON "demography"."citizens" ("country_id")
18 19 20 |
# File 'lib/pg_power/connection_adapters/postgresql_adapter/index_methods.rb', line 18 def index_name(table_name, ) #:nodoc: super.gsub('.','_') end |
#index_name_for_remove(table_name, options = {}) ⇒ Object
Overrides ActiveRecord::ConnectionAdapters::SchemaStatements.index_name_for_remove to support schema notation. Prepends the schema name to the index name.
Example
drop_index 'demography.citizens', :country_id
# produces
DROP INDEX "demography"."index_demography_citizens_on_country_id"
# instead of
DROP INDEX "index_demography_citizens_on_country_id"
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pg_power/connection_adapters/postgresql_adapter/index_methods.rb', line 32 def index_name_for_remove(table_name, = {}) index_name = super if table_name.include?('.') # schema notation schema = table_name.split('.').first "#{schema}.#{index_name}" else index_name end end |
#supports_partial_index? ⇒ Boolean
4 5 6 |
# File 'lib/pg_power/connection_adapters/postgresql_adapter/index_methods.rb', line 4 def supports_partial_index? true end |