fix(postgres): skip migration when db doesn't exist
All checks were successful
/ publish (push) Successful in 10s

This commit is contained in:
Hugo Renard 2024-09-18 18:23:03 +02:00
parent 44e05b66fe
commit 5373274a0e
Signed by: hougo
GPG key ID: 3A285FD470209C59

View file

@ -355,7 +355,13 @@ func bucketLifecycleRule() lshcore.LifecycleRule {
func (r *PostgresReconciler) migrateCollation(ctx context.Context, patcher *patch.SerialPatcher, postgres *lshcore.Postgres, pg *pgv1.Postgresql, db *sql.DB) error {
_, err := db.ExecContext(ctx,
fmt.Sprintf("ALTER DATABASE %s REFRESH COLLATION VERSION;", postgres.Spec.Database))
if err, ok := err.(*pq.Error); ok && err.Message == "invalid collation version change" {
if err, ok := err.(*pq.Error); ok {
if err.Code == "3D000" {
return nil
}
if err.Message != "invalid collation version change" {
return err
}
if conditions.IsTrue(postgres, lshmeta.OperationInProgress) {
return errors.New("operation already in progress")
}