﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25304	Allow management commands to check if database migrations are applied	Maxime Lorant	Mounir	"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."	New feature	closed	Core (Management commands)	1.8	Normal	fixed			Accepted	1	0	0	0	0	0
