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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user