Module: Viewmatic::Migration

Defined in:
lib/viewmatic/migration.rb

Overview

Helpers for creating and dropping views in ActiveRecord migrations.

Instance Method Summary collapse

Instance Method Details

#create_view(name) ⇒ Object

Create the view named in “name”. It must be defined in the view definitions file.

Parameters:

  • name (Symbol)


11
12
13
14
# File 'lib/viewmatic/migration.rb', line 11

def create_view(name)
  view = Viewmatic.view name
  execute SchemaStatements.create_view view
end

#drop_view(name, materialized: false) ⇒ Object

Drop the view named in “name”. It must be defined in the view definitions file.

Parameters:

  • name (Symbol)
  • materialized (Boolean) (defaults to: false)

    true if you’re dropping a materialized view



22
23
24
25
# File 'lib/viewmatic/migration.rb', line 22

def drop_view(name, materialized: false)
  view = View.new name, materialized: materialized
  execute SchemaStatements.drop_view view
end