Sha256: da6147d889bac9a0455e1012fb2d4057066a21ca9ece29ba6c7eb2a44e880f7d
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: false # @!parse # class ActiveRecord::Migration # # Refresh a materialized view # # # # @param [#to_s] name (nil) The qualified name of the view # # @option options [Boolean] :with_data (true) If the view should be populated after creation # # @option options [Symbol] :algorithm (nil) Makes the operation concurrent when set to :concurrently # # @return [void] # # # # The operation enables refreshing a materialized view # # by reloading its underlying SQL query: # # # # ```ruby # # refresh_materialized_view "admin_users" # # ``` # # # # The option `algorithm: :concurrently` acts exactly # # like in the `create_index` definition. You should # # possibly add the `disable_ddl_transaction!` command # # to the migration as well. # # # # With option `with_data: false` the command won't # # update the data. This option can't be used along with # # the `:algorithm`. # # # # The operation is always reversible, though its # # inversion does nothing. # def refresh_materialized_view(name, **options); end # end module PGTrunk::Operations::MaterializedViews # @private class RefreshMaterializedView < Base validate do errors.add :algorithm, :present if with_data == false && algorithm end validates :cluster_on, :columns, :force, :if_exists, :if_not_exists, :new_name, :sql_definition, :tablespace, :version, :comment, absence: true def to_sql(_version) sql = "REFRESH MATERIALIZED VIEW" sql << " CONCURRENTLY" if algorithm == :concurrently sql << " #{name.to_sql}" sql << " WITH NO DATA" if with_data == false sql << ";" end # The operation is reversible but its inversion does nothing def invert; end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pg_trunk-0.2.0 | lib/pg_trunk/operations/materialized_views/refresh_materialized_view.rb |
pg_trunk-0.1.3 | lib/pg_trunk/operations/materialized_views/refresh_materialized_view.rb |