Skip to content

Commit

Permalink
Fix unique indexes on issues and deps.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Jun 26, 2023
1 parent 8ad6604 commit acf6265
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion migration/v6/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ type Migration struct{}

func (r Migration) Apply(db *gorm.DB) (err error) {
m := db.Migrator()
err = m.DropIndex(model.TechDependency{}, "DepA")
err = m.DropIndex(model.TechDependency{}, "depA")
if err != nil {
return
}
err = m.DropIndex(model.Issue{}, "issueA")
if err != nil {
return
}
Expand Down
12 changes: 6 additions & 6 deletions migration/v6/model/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type Analysis struct {
// TechDependency report dependency.
type TechDependency struct {
Model
Provider string
Name string
Version string
SHA string
Provider string `gorm:"index:depA"`
Name string `gorm:"index:depA"`
Version string `gorm:"index:depA"`
SHA string `gorm:"index:depA"`
Indirect bool
Labels JSON `gorm:"type:json"`
AnalysisID uint `gorm:"index;not null"`
AnalysisID uint `gorm:"index;index:depA;not null"`
Analysis *Analysis
}

Expand All @@ -39,7 +39,7 @@ type Issue struct {
Facts JSON `gorm:"type:json"`
Labels JSON `gorm:"type:json"`
Effort int `gorm:"index;not null"`
AnalysisID uint `gorm:"index;not null"`
AnalysisID uint `gorm:"index;index:issueA;not null"`
Analysis *Analysis
}

Expand Down

0 comments on commit acf6265

Please sign in to comment.