chore(sticker): drop the retired per-user pack records at startup

The module stores nothing: /addsticker takes its pack from STICKER_PACK_NAME
and the set owner from OWNER_ID, and the factory ignores the collection it is
handed. Everything still in the sticker collection is therefore unreachable by
any code path — pack documents keyed by owner ID, "slug:" name reservations and
"pending-delete:" confirmations, all orphaned when the per-user commands were
removed.

InitStore lists and deletes them once per database, guarded by a systemstate
marker in the same shape as the stock and stats migrations. It aborts without
writing the marker so a partial run retries on the next boot, and deletes are
idempotent. A collection that is already empty is the normal case on a fresh
deploy and on the memory backend.

This permanently removes data. Back up the sticker collection before the first
deploy that carries it.
This commit is contained in:
tiennm99 committed 2026-09-04 11:37:29 +07:00
1 parent be91d2eb41
commit b903d14fc2
4 files changed
+262

No files matched your search

+17
View File
@@ -132,6 +132,9 @@ func main() {
if err := lol.InitStore(rootCtx, provider.Collection(lol.CollectionName)); err != nil {
log.Fatal("lol storage init failed", "err", err)
}
if err := initStickerStore(rootCtx, provider); err != nil {
log.Fatal("sticker storage init failed", "err", err)
}
migrationCtx, cancelMigration := context.WithTimeout(rootCtx, stockMigrationTimeout)
if err := initStockStore(migrationCtx, provider); err != nil {
cancelMigration()
@@ -246,6 +249,20 @@ func initStatsStoreWith(ctx context.Context, provider storage.Provider, init sta
)
}
func initStickerStore(ctx context.Context, provider storage.Provider) error {
return initStickerStoreWith(ctx, provider, sticker.InitStore)
}
type stickerStoreInitializer func(context.Context, storage.Collection, storage.Collection) error
func initStickerStoreWith(ctx context.Context, provider storage.Provider, init stickerStoreInitializer) error {
return init(
ctx,
provider.Collection(sticker.CollectionName),
provider.Collection(systemstate.CollectionName),
)
}
type stockStoreInitializer func(context.Context, storage.Collection, storage.Collection) error
func initStockStoreWith(ctx context.Context, provider storage.Provider, init stockStoreInitializer) error {