Skip to content

Commit

Permalink
CREATE MATERIALIZED VIEW IF NOT EXISTS
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz committed Oct 26, 2024
1 parent b8aecb3 commit 28206b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions storage/data/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (d *SQLDatabase) Init() error {
if err != nil {
return errors.Trace(err)
}
err = d.gormDB.Exec(fmt.Sprintf("CREATE MATERIALIZED VIEW %s_mv TO %s AS SELECT * FROM %s",
err = d.gormDB.Exec(fmt.Sprintf("CREATE MATERIALIZED VIEW IF NOT EXISTS %s_mv TO %s AS SELECT * FROM %s",
d.UserFeedbackTable(), d.UserFeedbackTable(), d.FeedbackTable())).Error
if err != nil {
return errors.Trace(err)
Expand All @@ -273,7 +273,7 @@ func (d *SQLDatabase) Init() error {
if err != nil {
return errors.Trace(err)
}
err = d.gormDB.Exec(fmt.Sprintf("CREATE MATERIALIZED VIEW %s_mv TO %s AS SELECT * FROM %s",
err = d.gormDB.Exec(fmt.Sprintf("CREATE MATERIALIZED VIEW IF NOT EXISTS %s_mv TO %s AS SELECT * FROM %s",
d.ItemFeedbackTable(), d.ItemFeedbackTable(), d.FeedbackTable())).Error
if err != nil {
return errors.Trace(err)
Expand Down

0 comments on commit 28206b6

Please sign in to comment.