mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
cff0f73e24
feat(init): add setting to enable durable locks on crdb
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package initialise
|
|
|
|
import (
|
|
_ "embed"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
"github.com/zitadel/logging"
|
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
|
)
|
|
|
|
func newSettings() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "settings",
|
|
Short: "Ensures proper settings on the database",
|
|
Long: `Ensures proper settings on the database.
|
|
|
|
Prerequisites:
|
|
- cockroachDB or postgreSQL
|
|
|
|
Cockroach
|
|
- Sets enable_durable_locking_for_serializable to on for the zitadel user and database
|
|
`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
config := MustNewConfig(viper.GetViper())
|
|
|
|
err := initialise(config.Database, VerifySettings(config.Database.DatabaseName(), config.Database.Username()))
|
|
logging.OnError(err).Fatal("unable to set settings")
|
|
},
|
|
}
|
|
}
|
|
|
|
func VerifySettings(databaseName, username string) func(*database.DB) error {
|
|
return func(db *database.DB) error {
|
|
if db.Type() == "postgres" {
|
|
return nil
|
|
}
|
|
logging.WithFields("user", username, "database", databaseName).Info("verify settings")
|
|
|
|
return exec(db, fmt.Sprintf(settingsStmt, databaseName, username), nil)
|
|
}
|
|
}
|