Skip to content

Commit

Permalink
add gorm constratint on asset_group_selectors (#92)
Browse files Browse the repository at this point in the history
Co-authored-by: Alyx Holms <[email protected]>
  • Loading branch information
irshadaj and superlinkx authored Sep 19, 2023
1 parent a8bb5bd commit a54704a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions cmd/api/src/database/migration/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ func ListBHModels() []any {

func (s *Migrator) gormAutoMigrate(models []any) error {
return s.db.Transaction(func(tx *gorm.DB) error {
if result := tx.Exec(`alter table if exists asset_group_selectors drop constraint if exists idx_asset_group_selectors_name;`); result.Error != nil {
return result.Error
}

for _, currentModel := range models {
if err := tx.Migrator().AutoMigrate(currentModel); err != nil {
return fmt.Errorf("failed to migrate model %T: %w", currentModel, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/api/src/model/agi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

type AssetGroupSelector struct {
AssetGroupID int32 `json:"asset_group_id"`
Name string `json:"name"`
Name string `json:"name" gorm:"unique"`
Selector string `json:"selector"`
SystemSelector bool `json:"system_selector"`

Expand Down

0 comments on commit a54704a

Please sign in to comment.