Module: Repertoire::Faceting::PostgreSQLAdapter::MigrationMethods
- Included in:
- Repertoire::Faceting::PostgreSQLAdapter
- Defined in:
- lib/repertoire-faceting/adapters/postgresql_adapter.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#create_materialized_view(view_name, sql) ⇒ Object
Methods used in creating, updating, and removing facet indices.
- #drop_materialized_view(view_name) ⇒ Object
-
#faceting_api_sql(api_name, schema_name) ⇒ Object
Returns the named PostgreSQL API binding sql; for shared hosts where you cannot build extensions.
- #refresh_materialized_view(view_name) ⇒ Object
Instance Method Details
#create_materialized_view(view_name, sql) ⇒ Object
Methods used in creating, updating, and removing facet indices
130 131 132 133 |
# File 'lib/repertoire-faceting/adapters/postgresql_adapter.rb', line 130 def create_materialized_view(view_name, sql) sql = "CREATE MATERIALIZED VIEW #{quote_table_name(view_name)} AS #{sql}" execute(sql) end |
#drop_materialized_view(view_name) ⇒ Object
140 141 142 143 |
# File 'lib/repertoire-faceting/adapters/postgresql_adapter.rb', line 140 def drop_materialized_view(view_name) sql = "DROP MATERIALIZED VIEW #{quote_table_name(view_name)} CASCADE" execute(sql) end |
#faceting_api_sql(api_name, schema_name) ⇒ Object
Returns the named PostgreSQL API binding sql; for shared hosts where you cannot build extensions
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/repertoire-faceting/adapters/postgresql_adapter.rb', line 146 def faceting_api_sql(api_name, schema_name) path = Repertoire::Faceting::MODULE_PATH version = Repertoire::Faceting::VERSION api_name = api_name.to_sym file_name = "#{path}/ext/#{api_name}/faceting_#{api_name}--#{version}.sql" raise "Use 'CREATE EXTENSION faceting' to load the default facet api" if api_name == :signature raise "Currently, the faceting API must install into a schema named 'facet'" unless schema_name == facet_schema # TODO This approach allows production deploys to skip a "rake db:extensions:install" step when installing # to Heroku. In practice, this eases deployment significantly. But shelling out to make during a # Rails migration feels inelegant. system "cd #{path}/ext; make" unless File.exist?(file_name) raise "No API binding available for #{api_name}" unless File.exist?(file_name) File.read(file_name).gsub(/@extschema@/, facet_schema) end |
#refresh_materialized_view(view_name) ⇒ Object
135 136 137 138 |
# File 'lib/repertoire-faceting/adapters/postgresql_adapter.rb', line 135 def refresh_materialized_view(view_name) sql = "REFRESH MATERIALIZED VIEW #{quote_table_name(view_name)}" execute(sql) end |