chore(queue): use schema config instead of search_path and application_name to configure the database schema (#10075)

Removes manual schema and application name setup via raw SQL and
switches to using River’s built-in schema configuration.

# Which Problems Are Solved

River provides a configuration flag to set the schema of the queue.
Zitadel sets the schema through database statements which is not needed
anymore.

# How the Problems Are Solved

Set the schema in the river configuration and removed old code
This commit is contained in:
Silvan
2025-07-29 09:09:00 +02:00
committed by GitHub
parent 416a35537f
commit b5f97d64b0
3 changed files with 2 additions and 43 deletions

View File

@@ -1,45 +1,6 @@
package queue
import (
"context"
"sync"
"github.com/jackc/pgx/v5"
"github.com/zitadel/zitadel/internal/database/dialect"
)
const (
schema = "queue"
applicationName = "zitadel_queue"
)
var conns = &sync.Map{}
type queueKey struct{}
func WithQueue(parent context.Context) context.Context {
return context.WithValue(parent, queueKey{}, struct{}{})
}
func init() {
dialect.RegisterBeforeAcquire(func(ctx context.Context, c *pgx.Conn) error {
if _, ok := ctx.Value(queueKey{}).(struct{}); !ok {
return nil
}
_, err := c.Exec(ctx, "SET search_path TO "+schema+"; SET application_name TO "+applicationName)
if err != nil {
return err
}
conns.Store(c, struct{}{})
return nil
})
dialect.RegisterAfterRelease(func(c *pgx.Conn) error {
_, ok := conns.LoadAndDelete(c)
if !ok {
return nil
}
_, err := c.Exec(context.Background(), "SET search_path TO DEFAULT; SET application_name TO "+dialect.DefaultAppName)
return err
})
}