2023-11-22 12:05:14 +00:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
_ "embed"
|
|
|
|
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2024-01-25 16:28:20 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2023-11-22 12:05:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
//go:embed 16.sql
|
|
|
|
uniqueConstraintLower string
|
|
|
|
)
|
|
|
|
|
|
|
|
type UniqueConstraintToLower struct {
|
|
|
|
dbClient *database.DB
|
|
|
|
}
|
|
|
|
|
2024-01-25 16:28:20 +00:00
|
|
|
func (mig *UniqueConstraintToLower) Execute(ctx context.Context, _ eventstore.Event) error {
|
2023-11-22 12:05:14 +00: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"
|
|
|
|
}
|