On ERROR and database integrity on migration

Asked by Yann Papouin

What happen if an error occurred when running migration script ?
Is there something like a massive transaction that will be triggered only if the migration is complete and successful or do I need to restore my database after every error and fix ?
Is there a "dry-run" option ?

Question information

Language:
English Edit question
Status:
Solved
For:
OpenUpgrade Server Edit question
Assignee:
No assignee Edit question
Solved by:
Yann Papouin
Solved:
Last query:
Last reply:
Revision history for this message
Holger Brunn (Therp) (hbrunn) said :
#1

We patched the server so that every migration runs in one transaction. The patch was necessary as some parts (mostly creating columns and such) do a commit afterwards and a rollback in the case of an error. We replaced that by savepoints.

And given that migrations run only once (he looks at the version number), restarting a migration after fixing the problem you encountered should just work.

We further patch the cursor class (in loading.py) so that calling commit/rollback does nothing.

Do you encounter problems with that or is this rather a theoretical question?

As for dry-runs: No, nothing like that up to now. That should be simple to implement as a monkey patch in loading.py too, I guess.

Revision history for this message
Holger Brunn (Therp) (hbrunn) said :
#2

... to be precise: Every migration _of_one_module_ runs in one transaction, that seems not to be clear from my previous comment

Revision history for this message
Yann Papouin (yann-papouin) said :
#3

Thank you, that was just a theoretical question.
Your answer is a really good start for migrating data as it allows me to fix thing modules by modules.