🗃️ Update modeling

This commit is contained in:
2024-08-24 15:17:26 +08:00
parent 5e76fa07b7
commit 516f5593de
7 changed files with 51 additions and 24 deletions

View File

@ -2,7 +2,9 @@ package services
import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/rs/zerolog/log"
"time"
)
func DoAutoDatabaseCleanup() {
@ -17,5 +19,8 @@ func DoAutoDatabaseCleanup() {
count += tx.RowsAffected
}
deadline := time.Now().Add(-30 * 24 * time.Hour)
database.C.Unscoped().Where("created_at <= ?", deadline).Delete(&models.Notification{})
log.Debug().Int64("affected", count).Msg("Clean up entire database accomplished.")
}