[bugfix] Drop status indices AFTER updating visibility (#3795)

* [bugfix] Drop status indices AFTER updating visibility

* rename to status vis indices just to indicate they're only used in the statuses hook func

---------

Co-authored-by: kim <grufwub@gmail.com>
This commit is contained in:
tobi 2025-02-14 13:52:04 +01:00 committed by GitHub
commit 879ca2d2f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 27 deletions

View file

@ -45,6 +45,7 @@ func convertEnums[OldType ~string, NewType ~int16](
column string,
mapping map[OldType]NewType,
defaultValue *NewType,
indexCleanupCallback func(context.Context, bun.Tx) error,
) error {
if len(mapping) == 0 {
return errors.New("empty mapping")
@ -110,6 +111,13 @@ func convertEnums[OldType ~string, NewType ~int16](
log.Warnf(ctx, "total=%d does not match updated=%d", total, updated)
}
// Run index cleanup callback if set.
if indexCleanupCallback != nil {
if err := indexCleanupCallback(ctx, tx); err != nil {
return gtserror.Newf("error running index cleanup callback: %w", err)
}
}
// Drop the old column from table.
if _, err := tx.NewDropColumn().
Table(table).