Fix migration

This commit is contained in:
Neil Alexander 2022-11-10 10:56:43 +00:00
parent 594ab15007
commit 6f7729e578
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -51,14 +51,14 @@ func UpServerNames(ctx context.Context, tx *sql.Tx, serverName gomatrixserverlib
pq.QuoteIdentifier(newTable), pq.QuoteIdentifier(newTable+"_pkey"),
)
if _, err := tx.ExecContext(ctx, q); err != nil {
return fmt.Errorf("drop PK from %q error: %w", newTable, err)
return fmt.Errorf("drop new PK from %q error: %w", newTable, err)
}
q = fmt.Sprintf(
"ALTER TABLE IF EXISTS %s DROP CONSTRAINT IF EXISTS %s;",
pq.QuoteIdentifier(oldTable), pq.QuoteIdentifier(oldTable+"_pkey"),
pq.QuoteIdentifier(newTable), pq.QuoteIdentifier(oldTable+"_pkey"),
)
if _, err := tx.ExecContext(ctx, q); err != nil {
return fmt.Errorf("drop PK from %q error: %w", oldTable, err)
return fmt.Errorf("drop old PK from %q error: %w", newTable, err)
}
}
return nil