Friday, October 2, 2015

Re: Corrupted Migration?

@James: Sorry, I misspoke! [field] actually corresponds to a old field in state X. Before adding the new fields in state Y, the migration is trying to remove some old fields in state X but isn't finding them. I think this means that I'm unable to re-run that migration since it's looking for state X fields to remove, but can't find them (the model is already in state Y). My confusion is in the fact that the model state wouldn't roll back to state X after the first failed transaction (like the DB did).

That makes even less sense than your original issue. Are you sure that migration X was applied properly? What versions of migrations are stored in your django_migrations table? Is the latest migration listed in there for your app? You should be able to find it with a raw SQL statement, something like "select * from django_migrations where app = '<app_name>';".

Does [field] currently exist in your database so that it can be removed? If not, you've had issues with migrations beyond this particular i

No. The model is all your own work. Anything you write stays written. The migration system tries to implement your work. If it fails, it will roll the database back to its previous state. It does nothing to your work. You need to take note of the failure, decide how to fix your work and try again.
ssue. Were any migration files removed? Does the database match migration X?

Even better, can you also post the full traceback that you receive during the failed migrations? That might lead to more clues.

Whoops, looks like part of my response got wrapped around Mike's by accident. Here's what it was supposed to say:

"That makes even less sense than your original issue. Are you sure that migration X was applied properly? What versions of migrations are stored in your django_migrations table? Is the latest migration listed in there for your app? You should be able to find it with a raw SQL statement, something like "select * from django_migrations where app = '<app_name>';".

Does [field] currently exist in your database so that it can be removed? If not, you've had issues with migrations beyond this particular issue. Were any migration files removed? Does the database match migration X?

Even better, can you also post the full traceback that you receive during the failed migrations? That might lead to more clues."

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUOs_XKiP2HyDHsPX6Gzk5ZO5m4Fedd62XrLGAwYZvF5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment