summaryrefslogtreecommitdiff
path: root/internal
diff options
from:
to:
context:
space:
mode:
authorGravatar SayaAndy <saya.andy@posteo.com> 2025-08-30 13:58:46 +0700
committerGravatar SayaAndy <saya.andy@posteo.com> 2025-08-30 13:58:46 +0700
commitc33d3b275f2580bff2d510715448c14be1d5d5b5 (patch)
tree8060ced0c4a0b4fed90e5a7abd9aaf782c38357a /internal
parent3d79cbf98ef66d916a1d255857f97368d864ffb6 (diff)
downloadweb-c33d3b275f2580bff2d510715448c14be1d5d5b5.tar.gz
web-c33d3b275f2580bff2d510715448c14be1d5d5b5.zip
fix: truncate likes table prior to dumping cache
Diffstat (limited to 'internal')
-rw-r--r--internal/router/client-cache.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/router/client-cache.go b/internal/router/client-cache.go
index 56cd595..b930d5a 100644
--- a/internal/router/client-cache.go
+++ b/internal/router/client-cache.go
@@ -76,6 +76,11 @@ func (c *ClientCache) Close() error {
return fmt.Errorf("fail to init transaction with db to dump cache: %w", err)
}
+ if _, err = tx.Exec("delete from blog_likes;"); err != nil {
+ tx.Rollback()
+ return fmt.Errorf("fail to truncate table blog_likes: %w", err)
+ }
+
userIdBytes := make(map[string][]byte)
sqlStatement := fmt.Sprintf(`