Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30597 closed Cleanup/optimization (fixed)

Improve documentation on reseting an app's migrations to zero.

Reported by: Keryn Knight Owned by: David Vaz
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Keryn Knight)

This came on IRC a while back, because someone didn't know how to effectively undo everything they'd done.

The entire documentation that I can find is as follows:
python manage.py migrate --help says Use the name "zero" to unapply all migrations, and so does this page. That's it.

It's not clear what unapplying migrations means, unless you're familiar with it already - it's not described on this page after searching for "unapply" or "undo" or "reset" or "restart" or "zero", nor is it clarified in the help text for the command, and the process of resetting an app's state to start-from-scratch isn't mentioned at all in the migrations docs, except for this tiny affordance.

Change History (17)

comment:1 by Keryn Knight, 5 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 5 years ago

Summary: Improve documentation on reseting an app's migrations to zeroImprove documentation on reseting an app's migrations to zero.
Type: New featureCleanup/optimization

Thanks for the report. I'm not sure how we could clarify what "unapplying" migrations means, it seems clear to me. Moreover my understanding is that it's not a common use case to unapply all migrations to "zero" state, so I don't think that it deserves a separate section in migrations topics.

migrations topics contains information that migrate is responsible for unapplying migrations and also a link to the migrate doc with zero option (added 6 years ago, see 162f7b938f6cff91b1e4d6086ddcc88cbb1a1cd6).

in reply to:  2 comment:3 by Keryn Knight, 5 years ago

Thanks for the report. I'm not sure how we could clarify what "unapplying" migrations means, it seems clear to me.

You're not the target audience though. Nor am I. All the synonyms I used in searching are ones I might expect new/inexperienced users to be looking for.

Moreover my understanding is that it's not a common use case to unapply all migrations to "zero" state, so I don't think that it deserves a separate section in migrations topics.

That it's uncommon is precisely why it should have documentation beyond the brief throwaway comment* the management command has. It's built in and supported! Every time someone has to do so for the first time, it's either under guidance from someone who knows better, or it's by trial and error. That should not be the case, because there is one way to do it, and one way only, and it's mostly that the concept isn't even discussed which leaves the user out in the cold.

It comes up relatively frequently on IRC that people get their migrations all in a muddle, and usually their answer is to just obliterate their database (sqlite usually) entirely (sometimes rightly, sometimes wrongly). But it's literally a solved problem from the framework's point of view: you can either reset to zero or your migrations and/or schema are so ruined that you need to start over or intervene manually.

* tbh, even South's documentation is better here, though it's almost as throwaway: Note that, if the system has already migrated past the specified migration, it will roll back to it instead. If you want to migrate all the way back, specify the special migration name zero

comment:4 by Mariusz Felisiak, 5 years ago

Triage Stage: UnreviewedAccepted

OK, agreed. We can evaluate PR with documentation improvement in this area.

comment:5 by Mariusz Felisiak, 5 years ago

Keryn, I hope you are interested in submitting a patch.

comment:6 by Tapasweni Pathak, 5 years ago

Hi folks: Can I PR?

comment:7 by David Vaz, 5 years ago

Owner: changed from nobody to David Vaz
Status: newassigned

in reply to:  7 comment:8 by David Vaz, 5 years ago

comment:9 by Mariusz Felisiak, 5 years ago

Has patch: set

comment:10 by Mariusz Felisiak, 5 years ago

Patch needs improvement: set

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 5d40de0:

[3.0.x] Refs #30597 -- Added a warning about dependent apps when unapplying migrations.

Backport of abba563c8635a52e8b657dee7708202e1f69433c from master

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In abba563c:

Refs #30597 -- Added a warning about dependent apps when unapplying migrations.

comment:13 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 1ac2f25e:

[2.2.x] Refs #30597 -- Added a warning about dependent apps when unapplying migrations.

Backport of abba563c8635a52e8b657dee7708202e1f69433c from master

comment:14 by Mariusz Felisiak, 5 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 45554fd5:

Fixed #30597 -- Clarified how to unapply migrations.

comment:16 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 0c655f1d:

[3.0.x] Fixed #30597 -- Clarified how to unapply migrations.

Backport of 45554fd5c5c6a536db3ce70d78646d3dc398cf08 from master

comment:17 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 4116b369:

[2.2.x] Fixed #30597 -- Clarified how to unapply migrations.

Backport of 45554fd5c5c6a536db3ce70d78646d3dc398cf08 from master

Note: See TracTickets for help on using tickets.
Back to Top