#25304: Allow management commands to check if database migrations are applied
-------------------------------------+-------------------------------------
Reporter: mlorant | Owner:
| MounirMesselmeni
Type: New feature | Status: assigned
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by MounirMesselmeni:
Old description:
> https://github.com/django/django/pull/5643
New description:
When creating a new project, you can sometimes forget to run `manage.py
migrate` before creating the initial superuser (especially if you don't
execute `runserver` before, which display a warning about migrations not
applied). The resulting error make sense, it can't access to auth_user,
since it does not exist yet:
{{{
$ django-admin.py startproject sample
$ cd sample/ && python manage.py createsuperuser
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
[...]
File
"/vagrant/django/django/contrib/auth/management/commands/createsuperuser.py",
line 85, in handle
default_username = get_default_username()
File
"/vagrant/django/django/contrib/auth/management/__init__.py", line 189, in
get_default_username
auth_app.User._default_manager.get(username=default_username)
[...]
File
"/vagrant/django/django/db/backends/sqlite3/base.py", line 323, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: auth_user
}}}
... but with a little try/except, it could be nicer and
give a more meaningful information:
{{{
$ python manage.py createsuperuser
CommandError: You must execute `manage.py migrate` once
before creating a super user
}}}
I have a patch ready (as I said, it just a try/except, see
attachment) but, if accepted, it would need unit tests to be complete.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25304#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.f5a26a027373beaca14b17f009a263c7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.