From 508d7720b6201a89a46810780a0256bf2fd7545d Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Mon, 13 Nov 2023 13:54:36 +0800 Subject: [PATCH] make trigger key index unique Signed-off-by: Yee Hing Tong --- flyteartifacts/pkg/db/gorm_models.go | 6 +++--- flyteartifacts/pkg/db/migrations.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flyteartifacts/pkg/db/gorm_models.go b/flyteartifacts/pkg/db/gorm_models.go index 101435a843..c13068b839 100644 --- a/flyteartifacts/pkg/db/gorm_models.go +++ b/flyteartifacts/pkg/db/gorm_models.go @@ -44,9 +44,9 @@ type Artifact struct { type TriggerKey struct { gorm.Model - Project string `gorm:"index:idx_pdn;index:idx_proj;type:varchar(64)"` - Domain string `gorm:"index:idx_pdn;index:idx_dom;type:varchar(64)"` - Name string `gorm:"index:idx_pdn;index:idx_name;type:varchar(255)"` + Project string `gorm:"uniqueIndex:idx_t_pdn;index:idx_t_proj;type:varchar(64)"` + Domain string `gorm:"uniqueIndex:idx_t_pdn;index:idx_t_dom;type:varchar(64)"` + Name string `gorm:"uniqueIndex:idx_t_pdn;index:idx_t_name;type:varchar(255)"` RunsOn []ArtifactKey `gorm:"many2many:active_trigger_artifact_keys;"` } diff --git a/flyteartifacts/pkg/db/migrations.go b/flyteartifacts/pkg/db/migrations.go index e91552f3e6..b09755115e 100644 --- a/flyteartifacts/pkg/db/migrations.go +++ b/flyteartifacts/pkg/db/migrations.go @@ -60,9 +60,9 @@ var Migrations = []*gormigrate.Migration{ Migrate: func(tx *gorm.DB) error { type TriggerKey struct { gorm.Model - Project string `gorm:"index:idx_t_pdn;index:idx_t_proj;type:varchar(64)"` - Domain string `gorm:"index:idx_t_pdn;index:idx_t_dom;type:varchar(64)"` - Name string `gorm:"index:idx_t_pdn;index:idx_t_name;type:varchar(255)"` + Project string `gorm:"uniqueIndex:idx_t_pdn;index:idx_t_proj;type:varchar(64)"` + Domain string `gorm:"uniqueIndex:idx_t_pdn;index:idx_t_dom;type:varchar(64)"` + Name string `gorm:"uniqueIndex:idx_t_pdn;index:idx_t_name;type:varchar(255)"` RunsOn []ArtifactKey `gorm:"many2many:active_trigger_artifact_keys;"` }