raises
RuntimeError: Error creating new content types. Please make sure
contenttypes is migrated before trying to migrate apps individually.
if migrations have not been applied or the database does not yet exist.
I think it should just exit normally in this case.
--
Ticket URL: <https://code.djangoproject.com/ticket/24369>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => Core (Management commands)
* needs_tests: => 0
* keywords: => flush
* needs_docs: => 0
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Suggested change:
{{{ #!diff
diff --git a/django/core/management/commands/flush.py
b/django/core/management/commands/flush.py
index 97c9450..eceb873 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -46,6 +46,10 @@ class Command(BaseCommand):
sql_list = sql_flush(self.style, connection, only_django=True,
reset_sequences=reset_sequences,
allow_cascade=allow_cascade)
+ if not sql_list:
+ raise CommandError(
+ "No commands to proceed with, maybe the database is still
empty?"
+ )
if interactive:
confirm = input("""You have requested a flush of the
database.
}}}
I'm not absolutely convinced about the need to write a test for that...
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:1>
Comment (by tanner):
looks good. thank you
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"9f1dbe29c0dbae57ff7950f3f64a0d083177cca8"]:
{{{
#!CommitTicketReference repository=""
revision="9f1dbe29c0dbae57ff7950f3f64a0d083177cca8"
Fixed #24369 -- Prevented crash when `flush`ing before db migration
Thanks Thomas Tanner for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:4>
Comment (by Claude Paroz <claude@…>):
In [changeset:"90ab6ee6123f2b378a068988526b409854ddec77"]:
{{{
#!CommitTicketReference repository=""
revision="90ab6ee6123f2b378a068988526b409854ddec77"
Revert "Fixed #24369 -- Prevented crash when `flush`ing before db
migration"
This reverts commit 9f1dbe29c0dbae57ff7950f3f64a0d083177cca8.
The proposed solution does not pass the test suite.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:5>
* status: closed => new
* resolution: fixed =>
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"767c33d1fa9827908192e8ed1ac7f281f56bd811"]:
{{{
#!CommitTicketReference repository=""
revision="767c33d1fa9827908192e8ed1ac7f281f56bd811"
Fixed #24369 -- Prevented crash when flushing before db migration
Thanks Thomas Tanner for the report and Tim Graham for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24369#comment:7>