Skip to content

Commit

Permalink
Merge pull request #102 from spowelljr/alterOwner
Browse files Browse the repository at this point in the history
Make postgres the owner of new materialized view
  • Loading branch information
medyagh authored Dec 6, 2023
2 parents dc5f510 + 7917754 commit bf9ae79
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ func (m *Postgres) createMaterializedView(env string, viewName string) error {
if _, err := m.db.Exec(createView); err != nil {
return err
}
// refresh the materialzed view
refreshView := fmt.Sprintf("REFRESH MATERIALIZED VIEW %s ;", viewName)
if _, err := m.db.Exec(refreshView); err != nil {

// if we add a new test environment the service account will be the owner of the newly created materalized view above
// but we require postgres to be the owner for the cron that refreshes the materialized view to run
alterOwner := fmt.Sprintf("ALTER MATERIALIZED VIEW %s OWNER TO postgres;", viewName)
if _, err := m.db.Exec(alterOwner); err != nil {
return err
}
return nil
Expand Down

0 comments on commit bf9ae79

Please sign in to comment.