CreateNamespaces creates namespaces in the target database without the need to have a running Temporal server. This exists primarily as a workaround for https://github.com/temporalio/temporal/issues/1336. Namespaces should typically be created through the Temporal API either via `tctl` or an SDK cl
(cfg *config.SQL, namespaces ...*NamespaceConfig)
| 91 | // |
| 92 | // Note: this function may receive breaking changes or be removed in the future. |
| 93 | func CreateNamespaces(cfg *config.SQL, namespaces ...*NamespaceConfig) error { |
| 94 | db, err := sql.NewSQLDB(sqlplugin.DbKindUnknown, cfg, resolver.NewNoopResolver(), log.NewNoopLogger(), metrics.NoopMetricsHandler) |
| 95 | if err != nil { |
| 96 | return fmt.Errorf("unable to create SQLite admin DB: %w", err) |
| 97 | } |
| 98 | defer func() { _ = db.Close() }() |
| 99 | |
| 100 | for _, ns := range namespaces { |
| 101 | if err := createNamespaceIfNotExists(db, ns); err != nil { |
| 102 | return fmt.Errorf("error creating namespace %q: %w", ns.Detail.Info.Name, err) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | // NewNamespaceConfig initializes a NamespaceConfig with the field values needed to pre-register |
| 110 | // the namespace via the CreateNamespaces function. |
no test coverage detected