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)
Change History (8)
comment:1 by , 10 years ago
by , 10 years ago
Attachment: | 24711.diff added |
---|
comment:2 by , 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 , 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 , 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 , 10 years ago
It would operate on the same tables, but "DROP" them instead of "TRUNCATE". By manged I meant, Options.managed.
comment:6 by , 10 years ago
Component: | Migrations → Core (Management commands) |
---|---|
Summary: | Flush manage command does not clear out migrations. → Allow flush management command to drop tables and re-run migrations |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
Version: | 1.8 → master |
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?