Use DELETE FROM instead of TRUNCATE for pgx#862
Open
HeroSizy wants to merge 2 commits intogolang-migrate:masterfrom
Open
Use DELETE FROM instead of TRUNCATE for pgx#862HeroSizy wants to merge 2 commits intogolang-migrate:masterfrom
HeroSizy wants to merge 2 commits intogolang-migrate:masterfrom
Conversation
Author
|
@dhui Any updates on getting this merged? Appreciate for your time. |
ce61c79 to
6e91d4e
Compare
Member
|
@HeroSizy @shawnzxx Sorry for the extremely slow response. I'm onboard with the change. A similar change was already made to MySQL but for different reasons. Could you also make the change to the postgres driver? Also, based on the article you linked, be aware that if there any migrations (e.g. DDL statements) that need to be applied, they'd still be blocked by the pg_dump run. |
HeroSizy
pushed a commit
to HeroSizy/migrate
that referenced
this pull request
Feb 28, 2024
Following this comment: golang-migrate#862 (comment) And reference PR: https://github.com/golang-migrate/migrate/pull/656/files
e29809a to
016d30d
Compare
Author
|
Hi @dhui , apologise for the slow response, I have just updated the isolation level. And also included pgx/v5 |
016d30d to
dcba639
Compare
HeroSizy
pushed a commit
to HeroSizy/migrate
that referenced
this pull request
Mar 1, 2025
Following this comment: golang-migrate#862 (comment) And reference PR: https://github.com/golang-migrate/migrate/pull/656/files
dcba639 to
2168b7a
Compare
HeroSizy
pushed a commit
to HeroSizy/migrate
that referenced
this pull request
Aug 6, 2025
Following this comment: golang-migrate#862 (comment) And reference PR: https://github.com/golang-migrate/migrate/pull/656/files
2168b7a to
0bb38a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In PostgreSQL, TRUNCATE statements cannot run during a db backup.
Deployment would be blocked by
db_dumpif there would be migration to run.db_dumprequiresACCESS SHARELOCKAnd will conflict with
TRUNCATEwhich requiresACCESS EXCLUSIVELOCKSolution
Use
DELETE FROMinstead ofTRUNCATEfor clearing the table since there is only one row of recordReference
Postgres
https://www.postgresql.org/docs/current/sql-truncate.html
Article about this scenario
https://www.dbi-services.com/blog/when-we-do-a-pg_dump-and-right-afterwards-truncate-a-table-which-is-in-the-dump-what-happens/
Edits
Edit 28-Feb-2024