Skip to content

Commit

Permalink
Use DELETE FROM instead of TRUNCATE for pgx
Browse files Browse the repository at this point in the history
  • Loading branch information
Zengyu committed Feb 28, 2024
1 parent a5dc5d1 commit 79a8d8e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion database/pgx/pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (p *Postgres) SetVersion(version int, dirty bool) error {
return &database.Error{OrigErr: err, Err: "transaction start failed"}
}

query := `TRUNCATE ` + quoteIdentifier(p.config.migrationsSchemaName) + `.` + quoteIdentifier(p.config.migrationsTableName)
query := `DELETE FROM ` + quoteIdentifier(p.config.migrationsSchemaName) + `.` + quoteIdentifier(p.config.migrationsTableName)
if _, err := tx.Exec(query); err != nil {
if errRollback := tx.Rollback(); errRollback != nil {
err = multierror.Append(err, errRollback)
Expand Down

0 comments on commit 79a8d8e

Please sign in to comment.