Modify

Ticket #1135 (closed defect: invalid)

Opened 22 months ago

Last modified 22 months ago

Running backwards migrations when forwards migrations fail is not useful

Reported by: klaas@… Owned by: andrew
Priority: major Milestone:
Component: commands Version: unknown
Keywords: Cc:

Description

Whenever south encounters an exception in the forward migration it tries to run the backward migration. (I suppose South doesn't do this when it can use transactions to do the reverting)

I think this is a mistake, for the following reasons:

  • Generally the fact that an error has occurred means the forward migration was not complete. So the state that is required for the backwards migration is not there yet. So in general the backwards migration will fail as well.
  • This is surely the case when multiple things are done in a single migration, e.g. add a column and directly add a unique index on it.
  • Many migrations don't have a backwards migration at all, either out of calculated laziness, or because one cannot exist.

This has the following detrimental effects:

  • The original error message when failing to migrate forward is occluded by the error that occurs when trying to revert.
  • It's hard to determine the state of the DB after 2 failed migrations (one of which failed at an unknown point due to the above).

See the below for someone else running into this:
http://stackoverflow.com/questions/10289106/not-sure-why-django-south-is-trying-to-run-reverse-migration

Attachments

Change History

comment:1 Changed 22 months ago by andrew

  • Status changed from new to closed
  • Resolution set to invalid

It's not actually running the backwards migration, it's just attempting to dry-run it to give you some useful SQL that you might want to run (there's no way we could run the right parts of it). If you're using a non-transactional-DDL database we really can't improve on this.

This error only occurs when the backwards migration is already broken, so it's not really a South bug. Plus, there's plans to do away with the whole dry-run business anyway and restructure the way that works, so I'm going to INVALID this for now.

comment:2 Changed 22 months ago by klaas@…

If you have plans to refactor everything anyway this should probably be ignored.

Just pointing out here that South suggests to create invalid backwards migrations in many cases itself (i.e. option 3 "Raise an exception" for backwards migration of a field that become null=True in the forwards migration).

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.