fix(api): enforce project identifier uniqueness
This commit is contained in:
@@ -8,7 +8,8 @@ import (
|
||||
var DBService *gorm.DB
|
||||
|
||||
func New(dsn string) error {
|
||||
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||
// 启用 Gorm 跨驱动错误翻译,业务层无需解析 Postgres 错误文本或 SQLSTATE。
|
||||
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{TranslateError: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user