mirror of
https://github.com/zitadel/zitadel.git
synced 2025-07-17 18:48:47 +00:00

# Which Problems Are Solved With v2.71.0 the `idp_templates6_ldap3` projection was created but never filled, as it was a subtable. To fix this we altered the `idp_templates6_ldap3` to `idp_templates6_ldap2` with v2.71.5. This was unfortunately without a check that the `idp_templates_ldap2`was already existing, which resulted in an error in the setup step. # How the Problems Are Solved Add check if `idp_templates6_ldap2` is already existing, before renaming `idp_templates6_ldap3` -> `idp_templates6_ldap2`. # Additional Changes None # Additional Context Closes #9669
48 lines
897 B
Go
48 lines
897 B
Go
package setup
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
_ "embed"
|
|
"errors"
|
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
var (
|
|
//go:embed 52/alter.sql
|
|
renameTableIfNotExisting string
|
|
//go:embed 52/check.sql
|
|
checkIfTableIsExisting string
|
|
)
|
|
|
|
type IDPTemplate6LDAP2 struct {
|
|
dbClient *database.DB
|
|
}
|
|
|
|
func (mig *IDPTemplate6LDAP2) Execute(ctx context.Context, _ eventstore.Event) error {
|
|
var count int
|
|
err := mig.dbClient.QueryRowContext(ctx,
|
|
func(row *sql.Row) error {
|
|
if err := row.Scan(&count); err != nil {
|
|
return err
|
|
}
|
|
return row.Err()
|
|
},
|
|
checkIfTableIsExisting,
|
|
)
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
if !errors.Is(err, sql.ErrNoRows) {
|
|
return err
|
|
}
|
|
_, err = mig.dbClient.ExecContext(ctx, renameTableIfNotExisting)
|
|
return err
|
|
}
|
|
|
|
func (mig *IDPTemplate6LDAP2) String() string {
|
|
return "52_idp_templates6_ldap2"
|
|
}
|