mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 05:02:18 +00:00
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
(cherry picked from commit b5f97d64b0)
38 lines
798 B
Go
38 lines
798 B
Go
package queue
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/riverqueue/river/riverdriver"
|
|
"github.com/riverqueue/river/riverdriver/riverpgxv5"
|
|
"github.com/riverqueue/river/rivermigrate"
|
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
|
)
|
|
|
|
type Migrator struct {
|
|
driver riverdriver.Driver[pgx.Tx]
|
|
}
|
|
|
|
func NewMigrator(client *database.DB) *Migrator {
|
|
return &Migrator{
|
|
driver: riverpgxv5.New(client.Pool),
|
|
}
|
|
}
|
|
|
|
func (m *Migrator) Execute(ctx context.Context) error {
|
|
_, err := m.driver.GetExecutor().Exec(ctx, "CREATE SCHEMA IF NOT EXISTS "+schema)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
migrator, err := rivermigrate.New(m.driver, &rivermigrate.Config{Schema: schema})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = migrator.Migrate(ctx, rivermigrate.DirectionUp, nil)
|
|
return err
|
|
|
|
}
|