mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:07:31 +00:00
feat: init migrations for transactional tables (#9946)
# Which Problems Are Solved To start with transactional tables we need to setup the new `zitadel` schema in a way that does not rely on the event store later. # How the Problems Are Solved Setup step added which calls the function which executes the migrations. # Additional Changes none # Additional Context - closes #9933
This commit is contained in:
38
cmd/setup/54.go
Normal file
38
cmd/setup/54.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
|
||||
v3_db "github.com/zitadel/zitadel/backend/v3/storage/database"
|
||||
"github.com/zitadel/zitadel/backend/v3/storage/database/dialect/postgres"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
type TransactionalTables struct {
|
||||
dbClient *database.DB
|
||||
}
|
||||
|
||||
func (mig *TransactionalTables) Execute(ctx context.Context, _ eventstore.Event) error {
|
||||
_, err := mig.dbClient.ExecContext(ctx, "CREATE SCHEMA IF NOT EXISTS zitadel")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config := &postgres.Config{Pool: mig.dbClient.Pool}
|
||||
pool, err := config.Connect(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return pool.(v3_db.Migrator).Migrate(ctx)
|
||||
}
|
||||
|
||||
func (mig *TransactionalTables) String() string {
|
||||
return "54_repeatable_transactional_tables"
|
||||
}
|
||||
|
||||
func (mig *TransactionalTables) Check(lastRun map[string]interface{}) bool {
|
||||
return true
|
||||
}
|
@@ -289,6 +289,9 @@ func Setup(ctx context.Context, config *Config, steps *Steps, masterKey string)
|
||||
&RiverMigrateRepeatable{
|
||||
client: dbClient,
|
||||
},
|
||||
&TransactionalTables{
|
||||
dbClient: dbClient,
|
||||
},
|
||||
}
|
||||
|
||||
for _, repeatableStep := range repeatableSteps {
|
||||
|
Reference in New Issue
Block a user