migrate icon indicating copy to clipboard operation
migrate copied to clipboard

Allow TRUNCATE for MySQL

Open ping-localhost opened this issue 2 years ago • 2 comments

Resolves issue https://github.com/golang-migrate/migrate/issues/864 which originates from https://github.com/golang-migrate/migrate/pull/656.


I agree that proper isolation is a must, but my database forces safe updates, which the current DELETE-query does not adhere to. To resolve that, I've added a simple switch to choose between DELETE and TRUNCATE.

Not sure if this is the best solution (we could also wrap the DELETE with SET SQL_SAFE_UPDATES), so feel free to edit/comment/etc.

ping-localhost avatar Dec 13 '23 08:12 ping-localhost

Coverage Status

coverage: 59.281% (+0.06%) from 59.226% when pulling 55c859def8d64175ce6913da0317bae234a53e1c on ping-localhost:added-safe-update-to-mysql-driver into a5dc5d1efc69e65f4f4c8f7c76c96a80da71a68a on golang-migrate:master.

coveralls avatar Dec 13 '23 09:12 coveralls

CI lint failure is not due to my changes, but because master itself is not compliant.

ping-localhost avatar Dec 14 '23 09:12 ping-localhost

Could this be solved by adding a LIMIT clause to the delete instead of moving back to truncate which is not transactional?

emeka avatar Apr 10 '24 12:04 emeka

Closing this in favor of https://github.com/golang-migrate/migrate/pull/1070

ping-localhost avatar Apr 15 '24 08:04 ping-localhost