From 83fdd336a38999addc246891194405551e70e902 Mon Sep 17 00:00:00 2001 From: SoXX Date: Wed, 3 Jul 2024 10:19:15 +0200 Subject: [PATCH] fix: do nothing by duplicate key Signed-off-by: SoXX --- internal/postgres/tag.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/postgres/tag.go b/internal/postgres/tag.go index e22426b..0270085 100644 --- a/internal/postgres/tag.go +++ b/internal/postgres/tag.go @@ -188,7 +188,10 @@ func CreateTagAlias(ctx context.Context, db *gorm.DB, tagAliasName models.Anthro return &otterError.EntityValidationFailed{Reason: otterError.AnthroveTagIDEmpty} } - result := db.WithContext(ctx).Create(&models.TagAlias{ + result := db.WithContext(ctx).Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "name"}}, + DoNothing: true, + }).Create(&models.TagAlias{ Name: string(tagAliasName), TagID: string(tagID), })