Skip to content

Commit bf9ae79

Browse files
authored
Merge pull request #102 from spowelljr/alterOwner
Make postgres the owner of new materialized view
2 parents dc5f510 + 7917754 commit bf9ae79

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/db/postgres.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ func (m *Postgres) createMaterializedView(env string, viewName string) error {
153153
if _, err := m.db.Exec(createView); err != nil {
154154
return err
155155
}
156-
// refresh the materialzed view
157-
refreshView := fmt.Sprintf("REFRESH MATERIALIZED VIEW %s ;", viewName)
158-
if _, err := m.db.Exec(refreshView); err != nil {
156+
157+
// if we add a new test environment the service account will be the owner of the newly created materalized view above
158+
// but we require postgres to be the owner for the cron that refreshes the materialized view to run
159+
alterOwner := fmt.Sprintf("ALTER MATERIALIZED VIEW %s OWNER TO postgres;", viewName)
160+
if _, err := m.db.Exec(alterOwner); err != nil {
159161
return err
160162
}
161163
return nil

0 commit comments

Comments
 (0)