Set on delete for jobs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
3fe5d510fe
commit
dea941df43
2 changed files with 12 additions and 5 deletions
|
|
@ -74,7 +74,7 @@ type Pool struct {
|
|||
GitHubRunnerGroup string
|
||||
|
||||
RepoID *uuid.UUID `gorm:"index"`
|
||||
Repository Repository `gorm:"foreignKey:RepoID"`
|
||||
Repository Repository `gorm:"foreignKey:RepoID;"`
|
||||
|
||||
OrgID *uuid.UUID `gorm:"index"`
|
||||
Organization Organization `gorm:"foreignKey:OrgID"`
|
||||
|
|
@ -92,7 +92,8 @@ type Repository struct {
|
|||
Owner string `gorm:"index:idx_owner_nocase,unique,collate:nocase"`
|
||||
Name string `gorm:"index:idx_owner_nocase,unique,collate:nocase"`
|
||||
WebhookSecret []byte
|
||||
Pools []Pool `gorm:"foreignKey:RepoID"`
|
||||
Pools []Pool `gorm:"foreignKey:RepoID"`
|
||||
Jobs []WorkflowJob `gorm:"foreignKey:RepoID;constraint:OnDelete:SET NULL"`
|
||||
}
|
||||
|
||||
type Organization struct {
|
||||
|
|
@ -101,7 +102,8 @@ type Organization struct {
|
|||
CredentialsName string
|
||||
Name string `gorm:"index:idx_org_name_nocase,collate:nocase"`
|
||||
WebhookSecret []byte
|
||||
Pools []Pool `gorm:"foreignKey:OrgID"`
|
||||
Pools []Pool `gorm:"foreignKey:OrgID"`
|
||||
Jobs []WorkflowJob `gorm:"foreignKey:OrgID;constraint:OnDelete:SET NULL"`
|
||||
}
|
||||
|
||||
type Enterprise struct {
|
||||
|
|
@ -110,7 +112,8 @@ type Enterprise struct {
|
|||
CredentialsName string
|
||||
Name string `gorm:"index:idx_ent_name_nocase,collate:nocase"`
|
||||
WebhookSecret []byte
|
||||
Pools []Pool `gorm:"foreignKey:EnterpriseID"`
|
||||
Pools []Pool `gorm:"foreignKey:EnterpriseID"`
|
||||
Jobs []WorkflowJob `gorm:"foreignKey:EnterpriseID;constraint:OnDelete:SET NULL"`
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ func (s *sqlDatabase) cascadeMigrationSQLite(model interface{}, name string, jus
|
|||
}
|
||||
}
|
||||
|
||||
if strings.Contains(data, "ON DELETE CASCADE") {
|
||||
if strings.Contains(data, "ON DELETE") {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -178,6 +178,10 @@ func (s *sqlDatabase) cascadeMigration() error {
|
|||
if err := s.cascadeMigrationSQLite(&Tag{}, "pool_tags", false); err != nil {
|
||||
return fmt.Errorf("failed to migrate addresses: %w", err)
|
||||
}
|
||||
|
||||
if err := s.cascadeMigrationSQLite(&WorkflowJob{}, "workflow_jobs", false); err != nil {
|
||||
return fmt.Errorf("failed to migrate addresses: %w", err)
|
||||
}
|
||||
case config.MySQLBackend:
|
||||
return nil
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue