#32827: Squashing migrations isn't very effective in complicated projects;
rewrite
docs to provide a preferred manual trimming process
-------------------------------------+-------------------------------------
Reporter: Mike Lissner | Owner: Mike
Type: | Lissner
Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
squashmigration, documentation |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by David Sanders):
@Carlton & Nessita:
I agree there needs to be a bit in the docs for this; Mike has stepped
down as he doesn't have any time but I have some time:
- I agree that it should be "manually squashing" vs "automatic squashing"
- I've only tried `squashmigrations` twice but both times failed and
ended up costing me quite a few hours that my boss wasn't too happy about
:D
- The first time there was this circular dependency nightmare that I
couldn't escape
- The second I had to write some custom serialisation to deal with
django-pgtrigger & in the end it didn't work out (I don't remember all the
details as this was a few months ago)
- I decided to finally manually squash them, but using the "replaces"
feature that `squashmigrations` uses – and it worked a treat plus it
didn't take very long!
- The key thing to remember is that you *must* note down all the non-
elidable operations.
- These are the steps I used (they'll need to be tailored for general
public):
- I rm'd all my migrations
- ran makemigrations (giving it a distinct new initial name)
- used git to restore all the rm'd migrations
- copy all the filenames into the `replaces` attribute
- copied all my non-elidable operations *plus any dependencies* into
the new initial migration
- wait until all deployments have been migrated out of the "replaces
zone" then follow the rest of the instructions on the docs
Sounded like Jessamyn had some issues with missing the custom user model -
I didn't encounter this issue even though my user model was in the app I
squashed 🤔
I'd like to forward a PR if that's ok.
--
Ticket URL: <https://code.djangoproject.com/ticket/32827#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070187cd6ae6ea-bb14ee70-13bf-438d-9117-48dae9a3878b-000000%40eu-central-1.amazonses.com.