Opened 10 years ago

Last modified 8 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

Description

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 10 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Tim Graham, 10 years ago

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?

by Tim Graham, 10 years ago

Attachment: 24711.diff added

comment:2 by Pradeek, 10 years ago

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 by Tim Graham, 10 years ago

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 by Pradeek, 10 years ago

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 by Tim Graham, 10 years ago

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

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

comment:6 by Tim Graham, 10 years ago

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 by Tim Graham <timograham@…>, 10 years ago

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