fix(api): enforce project identifier uniqueness

This commit is contained in:
2026-07-21 14:41:30 +08:00
parent 5341b44cc5
commit 14a140985c
6 changed files with 89 additions and 31 deletions

View File

@@ -5,10 +5,10 @@ import "time"
type SenlinAgentProject struct {
ID uint `gorm:"primaryKey"`
Identity string `gorm:"type:char(36);uniqueIndex"`
OwnerID uint `gorm:"index;not null"`
OwnerID uint `gorm:"index;not null;uniqueIndex:uidx_senlin_agent_projects_owner_identifier,priority:1"`
OwnerIdentity string `gorm:"type:char(36);index"`
Name string `gorm:"not null"`
Identifier string `gorm:"index"`
Identifier string `gorm:"index;uniqueIndex:uidx_senlin_agent_projects_owner_identifier,priority:2"`
Icon string
Background string
Description string