avram icon indicating copy to clipboard operation
avram copied to clipboard

Add macro helpers + documentation for supporting materialized views

Open robcole opened this issue 2 years ago • 1 comments

Per chat in discord:

Current approach:

class ModelName < BaseModel
  skip_schema_enforcer

  table do
    ...
  end

Ideas:

view :materialized do
end

robcole avatar May 19 '22 03:05 robcole

Not 100% sold on that as it could look like that's how you name the view.... But my thought is, if we can detect that it's a materialized view here, then we can also add a helper method like this:

def self.refresh_view(*, concurrent : Bool = false)
    database.exec("REFRESH MATERIALIZED VIEW #{concurrent ? "CONCURRENTLY" : ""} #{table_name}")
  end

jwoertink avatar May 20 '22 16:05 jwoertink