Skip to content

Commit

Permalink
fix(backend): clear views before auto migrate (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrimIdan committed Nov 6, 2022
1 parent 0e285b5 commit dbec182
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,14 @@ func initDataBase(config *DBConfig) *gorm.DB {

setupJoinTables(db)

// recreate views from scratch
dropAllViews(db)

// this will ensure table is created
if err := db.AutoMigrate(Application{}, Resource{}, Package{}, Vulnerability{}, NewVulnerability{}, QuickScanConfig{}, Scheduler{}, CISDockerBenchmarkCheck{}); err != nil {
log.Fatalf("Failed to run auto migration: %v", err)
}

// recreate views from scratch
dropAllViews(db)
createAllViews(db)

return db
Expand Down

0 comments on commit dbec182

Please sign in to comment.