Opened 7 years ago

Last modified 5 years ago

#24711 new New feature

Allow flush management command to drop tables and re-run migrations

Reported by: Pradeek Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This means that after running flush, migrate does not have any effect. This makes it difficult when the migrate command is responsible for loading fixtures, which according to the docs seems to be the way forward.

Looking for feedback on how we want to do this. Should we clear the migrations table on flush or should there be a flag that has to be manually added?

Attachments (1)

24711.diff (725 bytes) - added by Tim Graham 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by Tim Graham

Clearing the migrations history would mean that all schema migrations would need to be faked. I think it would be easier to drop the database and re-run the migrations. Attached is a proposed documentation patch to suggest that. What do you think?

Changed 7 years ago by Tim Graham

Attachment: 24711.diff added

comment:2 Changed 7 years ago by Pradeek

The reason why I proposed this, is because Django previously loaded initial data during flush. Such a functionality cannot be replicated here without going outside the management commands and dropping the db manually. I personally think flush without loading fixtures (assuming migrations will be the only way to do initial data in the future) would not be of much use / and feels broken. I think we should be able to fake schema migrations but still run python migrations on flush.

comment:3 Changed 7 years ago by Tim Graham

The problem what that approach is that older data migrations may not run on the current version of the schema.

An option to "flush" by deleting all managed tables and re-running migrations from the beginning might be acceptable. In the meantime, does the documentation patch look okay?

comment:4 Changed 7 years ago by Pradeek

Yeah. The documentation patch is fine.

Reg adding an option to flush, what other managed tables should be cleared? Will take a crack at adding it.

comment:5 Changed 7 years ago by Tim Graham

It would operate on the same tables, but "DROP" them instead of "TRUNCATE". By managed I meant, Options.managed.

Last edited 5 years ago by Anton Samarchyan (previous) (diff)

comment:6 Changed 7 years ago by Tim Graham

Component: MigrationsCore (Management commands)
Summary: Flush manage command does not clear out migrations.Allow flush management command to drop tables and re-run migrations
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature
Version: 1.8master

comment:7 Changed 7 years ago by Tim Graham <timograham@…>

In 4870b30:

Removed initial data from flush docs since it's removed; refs #24711.

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