fix(conga): queue:clear reuses the app's published database (quick-261106-kt2)

Run in-process on an app that already published its pool, queue:clear failed
with "backpack: duplicate provider for *sql.DB". It now goes through
withAppDB; the CLI path is unchanged.
This commit is contained in:
Jakub Zych
2026-11-06 15:28:08 +01:00
parent 16a20088a3
commit 99abe88b6a
2 changed files with 20 additions and 3 deletions

View File

@@ -120,7 +120,7 @@ asks first; --force skips the question. Off a terminal it never asks.`,
if err := confirmProduction(app, in, out, fmt.Sprintf("Delete every pending job of queue %q in production?", queue)); err != nil {
return err
}
return withDB(ctx, app, func() error {
return withAppDB(ctx, app, func() error {
return clearQueue(ctx, app, queue, out)
})
},
@@ -336,7 +336,9 @@ func dueAt(c pact.Cadence, t time.Time) bool {
}
// withAppDB runs fn with the app's database: the published one when there is
// one, otherwise one opened for the command the way withDB does.
// one, otherwise one opened for the command the way withDB does. It serves
// schedule:run --once and queue:clear, which may run in-process on an app
// that already published its pool.
func withAppDB(ctx context.Context, app *backpack.App, fn func() error) error {
if gdb, ok := app.Lookup[*gorm.DB](); ok && gdb != nil {
return fn()