Skip to content

Commit

Permalink
Add cascade on tags
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
  • Loading branch information
gabriel-samfira committed Jun 28, 2023
1 parent e578ac1 commit aca4dcc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions database/sql/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Tag struct {
Base

Name string `gorm:"type:varchar(64);uniqueIndex"`
Pools []*Pool `gorm:"many2many:pool_tags;"`
Pools []*Pool `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE"`
}

type Pool struct {
Expand All @@ -65,7 +65,7 @@ type Pool struct {
Flavor string `gorm:"index:idx_pool_type"`
OSType params.OSType
OSArch params.OSArch
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE"`
Enabled bool
// ExtraSpecs is an opaque json that gets sent to the provider
// as part of the bootstrap params for instances. It can contain
Expand Down Expand Up @@ -144,7 +144,7 @@ type Instance struct {
OSArch params.OSArch
OSName string
OSVersion string
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE"`
Status common.InstanceStatus
RunnerStatus common.RunnerStatus
CallbackURL string
Expand All @@ -158,7 +158,7 @@ type Instance struct {
PoolID uuid.UUID
Pool Pool `gorm:"foreignKey:PoolID"`

StatusMessages []InstanceStatusUpdate `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
StatusMessages []InstanceStatusUpdate `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE"`
}

type User struct {
Expand Down

0 comments on commit aca4dcc

Please sign in to comment.