[Django] #24484: Poor user experience with migrations and running tests

11 views
Skip to first unread message

Django

unread,
Mar 14, 2015, 1:39:26 PM3/14/15
to django-...@googlegroups.com
#24484: Poor user experience with migrations and running tests
-------------------------------+--------------------
Reporter: acdha | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Prior to Django 1.7, you could create a new app and run tests immediately:

django-admin.py startapp new_app
… add a model & test …
django-admin.py test

Since Django 1.7, however, if you don't run makemigrations first the tests
will fail in a manner which doesn't give any indication of what you can do
to fix it. setup_databases() will eventually fail with a
"OperationalError: no such table" for every model which doesn't have an
initial migration.

I'm filing this under documentation because the easiest path to solve it
would be updating the startapp and running tests docs to add a prominent
notice somewhere that you must run makemigrations before you can run any
tests but if there's a clean way to do it having setup_databases catch
this and give a helpful message would probably save people some searching.

--
Ticket URL: <https://code.djangoproject.com/ticket/24484>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 16, 2015, 1:40:16 PM3/16/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* component: Documentation => Testing framework
* needs_tests: => 0
* version: 1.7 => master
* needs_docs: => 0
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

It seems better to exit with a helpful message rather than have to lookup
some documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:1>

Django

unread,
Mar 22, 2015, 9:59:16 AM3/22/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by kaedroho):

* status: new => assigned
* owner: nobody => kaedroho


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:2>

Django

unread,
Mar 28, 2015, 11:34:19 AM3/28/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
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
--------------------------------------+------------------------------------
Changes (by MarkusH):

* has_patch: 0 => 1


Comment:

PR https://github.com/django/django/pull/4379

--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:3>

Django

unread,
Mar 28, 2015, 1:11:53 PM3/28/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by MarkusH):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:4>

Django

unread,
Mar 28, 2015, 3:04:01 PM3/28/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by MarkusH):

Please note #24412 which requests a similar change.

--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:5>

Django

unread,
Aug 4, 2015, 3:03:29 AM8/4/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by pzrq):

Ended up looking at this as part of my PyConAU yak shaving.

Squashed version for master:
https://github.com/django/django/pull/5100

Full branch, tests and reasoning in commits for code review:
https://github.com/pzrq/django/compare/ticket-24484-4

Squashed version rebased (some minor test merge conflicts) for 1.8:
https://github.com/pzrq/django/compare/ticket-24484-4-squash-18

Let me know if anyone has any questions, e.g. it took my aging 2011
Macbook Air an extra ~17 seconds to run the `has_unmigrated_models` before
it was renamed to `check_unmigrated_models` and some further refactoring
applied. I also haven't thought about things like any possible
interactions with things like `--keepdb`, just run it against the full
test suite under Python 3.4.

--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:6>

Django

unread,
Aug 4, 2015, 9:33:34 AM8/4/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
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
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:7>

Django

unread,
Aug 27, 2015, 2:34:50 PM8/27/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: 1.9 | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* keywords: => 1.9


* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:8>

Django

unread,
Sep 17, 2015, 7:26:29 PM9/17/15
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: acdha | Owner: kaedroho
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* keywords: 1.9 =>


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:9>

Django

unread,
Sep 15, 2020, 6:01:03 AM9/15/20
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
--------------------------------------+------------------------------------
Reporter: Chris Adams | Owner: (none)
Type: Cleanup/optimization | Status: new

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* owner: Karl Hobley => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:10>

Django

unread,
Sep 30, 2022, 2:16:33 AM9/30/22
to django-...@googlegroups.com
#24484: Add a helpful message when running tests with models without migrations
-------------------------------------+-------------------------------------
Reporter: Chris Adams | Owner: Aman
Type: | Pandey
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Aman Pandey):

* owner: (none) => Aman Pandey


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/24484#comment:11>

Reply all
Reply to author
Forward
0 new messages