2023-11-22 14:05:14 +02:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
_ "embed"
|
|
|
|
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2024-01-25 17:28:20 +01:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2023-11-22 14:05:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
//go:embed 16.sql
|
|
|
|
uniqueConstraintLower string
|
|
|
|
)
|
|
|
|
|
|
|
|
type UniqueConstraintToLower struct {
|
|
|
|
dbClient *database.DB
|
|
|
|
}
|
|
|
|
|
2024-01-25 17:28:20 +01:00
|
|
|
func (mig *UniqueConstraintToLower) Execute(ctx context.Context, _ eventstore.Event) error {
|
2023-11-22 14:05:14 +02:00
|
|
|
res, err := mig.dbClient.ExecContext(ctx, uniqueConstraintLower)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
count, err := res.RowsAffected()
|
|
|
|
logging.WithFields("count", count).Info("unique constraints updated")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mig *UniqueConstraintToLower) String() string {
|
|
|
|
return "16_unique_constraint_lower"
|
|
|
|
}
|