From b10798d71fd02bc7d9db7ced8330a3ab983782a5 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 20 Jan 2024 11:36:12 -0500 Subject: [PATCH] fix: update TusLock to use a compound unique index to work with soft deletes --- db/models/tus_lock.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/models/tus_lock.go b/db/models/tus_lock.go index 63e8456..b6f1cef 100644 --- a/db/models/tus_lock.go +++ b/db/models/tus_lock.go @@ -14,11 +14,12 @@ var ( type TusLock struct { gorm.Model - LockId string `gorm:"uniqueIndex"` + LockId string `gorm:"index:idx_lock_id,unique"` HolderPID int `gorm:"index"` AcquiredAt time.Time ExpiresAt time.Time - ReleaseRequested bool `gorm:"default:false"` + ReleaseRequested bool + DeletedAt gorm.DeletedAt `gorm:"index:idx_lock_id,unique"` } func (t *TusLock) TryLock(db *gorm.DB, ctx context.Context) error {