[Django] #23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848 may need attention

1,344 views
Skip to first unread message

Django

unread,
Aug 26, 2014, 4:25:38 PM8/26/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
-------------------------------+--------------------
Reporter: stevejalim | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
May I suggest either an extension to the fix made in #22848 or a note in
documentation about it?

(TLDR for that ticket: starting a project with a custom user model and no
migrations yet led to an exception when `makemigrations` was run, so
@andrewgodwin added a special case for the creation of a first migration)

I just hit what appeared to be the same issue myself, found the ticket,
checked my Django version (1.7 RC3) and thought all should be well, but I
thought it still wasn't working for me until I actually read the patch and
saw why:

There's still a subtle gotcha where `makemigrations --list` will still
throw the dependency error, while `makemigrations <app name>` will happily
run. So if someone gets Dependency on app with no migrations when starting
`runserver` and they then try to check their migrations list, they will be
prevented from doing so and they have no cue to as to what they can do to
remedy things.

It's a corner case, sure, but likely will lead to user frustration for
those stuck in that corner.

One solution would be to extend the no-migrations behaviour to `--list`.
Alternatively if we collectively just want a patch for the docs, I'd be
happy to submit one. I think the an aside in the custom user docs seems a
sensible place, but it would need a little background added in the same
patch, too. Anyone disagree?

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

Django

unread,
Aug 26, 2014, 4:27:21 PM8/26/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+--------------------------------------
Reporter: stevejalim | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by stevejalim):

* needs_better_patch: => 0
* component: Uncategorized => Migrations
* needs_tests: => 0
* version: 1.6 => 1.7-rc-3
* easy: 0 => 1
* needs_docs: => 0
* type: Uncategorized => Bug


Comment:

I'd actually call this a release blocker, given that it stops development
in its tracks if you fall into the hole. However, I'm not familiar enough
with the project triage process to make that call.

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

Django

unread,
Aug 28, 2014, 2:01:04 PM8/28/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: nobody

Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* stage: Unreviewed => Accepted


Comment:

I agree this is an issue but not a release blocker; it's not a crash but
an exit with a genuine error message.

That said, the fix is relatively simple, in that we should make `--list`
also enable the mode where it gets to ignore these errors.

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

Django

unread,
Sep 5, 2014, 4:43:26 PM9/5/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: nobody

Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by x110dc):

I have no particular expertise here but I'm at the DjangoCon sprint so I
thought I'd see if I could help. :-) There's two things on this ticket
that confuse me: (1) there's no `--list` option to `makemigrations`. Did
you mean `migrate`? Or has this changed since the ticket was created? and
(2) I can't reproduce the error. I started a new (empty) Django project,
added the sample custom User model from #22848, tried a `migrate --list`
and didn't get any errors. Can you show exactly what sequence created the
error?

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

Django

unread,
Sep 5, 2014, 5:38:17 PM9/5/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: nobody

Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by stevejalim):

Yes, my typo. It would have been `./manage migrate --list` (I have aliases
set up, so conflated the terms).

Interesting that you can't reproduce it. Will try to find time to
replicate it in a standalone proj

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

Django

unread,
Sep 12, 2014, 3:00:01 AM9/12/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: nobody

Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by lukas-schulze):

In a standalone project you can easily reproduce it with an
AbstractBaseUser:

{{{
class MyUser(AbstractBaseUser):
email = models.EmailField('E-Mail', unique=True)

USERNAME_FIELD = 'email'
}}}

Add to your setting.py {{{AUTH_USER_MODEL = 'accounts.MyUser'}}} and now
run
$ ./manage.py migrate --list

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

Django

unread,
Sep 16, 2014, 7:47:25 PM9/16/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+---------------------------------------
Reporter: stevejalim | Owner: sharifmamun
Type: Bug | Status: assigned

Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+---------------------------------------
Changes (by sharifmamun):

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


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

Django

unread,
Oct 30, 2014, 9:37:17 AM10/30/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+---------------------------------------
Reporter: stevejalim | Owner: sharifmamun
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* has_patch: 0 => 1
* version: 1.7-rc-3 => 1.7
* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/3234 PR 3234] needs tests.

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

Django

unread,
Nov 15, 2014, 6:32:25 AM11/15/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky

Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------
Changes (by yakky):

* owner: sharifmamun => yakky


Comment:

Assigning this to me to write tests

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

Django

unread,
Nov 15, 2014, 7:24:57 AM11/15/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by yakky):

I cannot reproduce this either.

Steps taken:

* django-admin startproject whatever
* Create an `accounts` application with `models.py` containing the
`MyUser` model detailed above
* Add `accounts` to `INSTALLED_APPS`
* Add `AUTH_USER_MODEL = 'accounts.MyUser'` at the bottom of the settings
* run `./manage.py migrate --list`
* Outputs the migrations for `admin`, `auth`, `contenttypes`, `sessions`

Tested on 1.7c3, 1.7, 1.7.1 versions

Apparently nothing has changed in `MigrationLoader` class since mid-june,
so no idea what triggered the message in the first place

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

Django

unread,
Nov 15, 2014, 7:25:18 AM11/15/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------
Changes (by yakky):

* cc: yakky (added)


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

Django

unread,
Nov 15, 2014, 8:17:53 AM11/15/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by yakky):

I set up a
[https://github.com/yakky/django/commit/624b84a034cb59227330af6fba2bfdba114699f1
test] to test the failure

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

Django

unread,
Dec 30, 2014, 8:02:51 AM12/30/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------
Description changed by MarkusH:

Old description:

> May I suggest either an extension to the fix made in #22848 or a note in
> documentation about it?
>
> (TLDR for that ticket: starting a project with a custom user model and no
> migrations yet led to an exception when `makemigrations` was run, so
> @andrewgodwin added a special case for the creation of a first migration)
>
> I just hit what appeared to be the same issue myself, found the ticket,
> checked my Django version (1.7 RC3) and thought all should be well, but I
> thought it still wasn't working for me until I actually read the patch
> and saw why:
>
> There's still a subtle gotcha where `makemigrations --list` will still
> throw the dependency error, while `makemigrations <app name>` will
> happily run. So if someone gets Dependency on app with no migrations when
> starting `runserver` and they then try to check their migrations list,
> they will be prevented from doing so and they have no cue to as to what
> they can do to remedy things.
>
> It's a corner case, sure, but likely will lead to user frustration for
> those stuck in that corner.
>
> One solution would be to extend the no-migrations behaviour to `--list`.
> Alternatively if we collectively just want a patch for the docs, I'd be
> happy to submit one. I think the an aside in the custom user docs seems a
> sensible place, but it would need a little background added in the same
> patch, too. Anyone disagree?

New description:

May I suggest either an extension to the fix made in #22848 or a note in
documentation about it?

(TLDR for that ticket: starting a project with a custom user model and no
migrations yet led to an exception when `makemigrations` was run, so
@andrewgodwin added a special case for the creation of a first migration)

I just hit what appeared to be the same issue myself, found the ticket,
checked my Django version (1.7 RC3) and thought all should be well, but I
thought it still wasn't working for me until I actually read the patch and
saw why:

There's still a subtle gotcha where `migrate --list` will still throw the


dependency error, while `makemigrations <app name>` will happily run. So
if someone gets Dependency on app with no migrations when starting
`runserver` and they then try to check their migrations list, they will be
prevented from doing so and they have no cue to as to what they can do to
remedy things.

It's a corner case, sure, but likely will lead to user frustration for
those stuck in that corner.

One solution would be to extend the no-migrations behaviour to `--list`.
Alternatively if we collectively just want a patch for the docs, I'd be
happy to submit one. I think the an aside in the custom user docs seems a
sensible place, but it would need a little background added in the same
patch, too. Anyone disagree?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/23366#comment:12>

Django

unread,
Dec 31, 2014, 5:25:00 PM12/31/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by timgraham):

Not sure why the test doesn't reproduce the failure, but I can reproduce
this manually. Since apps without migrations will be obsolete in 1.9, I
don't think this is worth spending any more time on so I'll just commit
this without a test.

--
Ticket URL: <https://code.djangoproject.com/ticket/23366#comment:13>

Django

unread,
Dec 31, 2014, 5:26:53 PM12/31/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b4bdd5262b18644456d12a00d475adf9897a9255"]:
{{{
#!CommitTicketReference repository=""
revision="b4bdd5262b18644456d12a00d475adf9897a9255"
Fixed #23366 -- Fixed a crash with the migrate --list command.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23366#comment:14>

Django

unread,
Dec 31, 2014, 5:42:27 PM12/31/14
to django-...@googlegroups.com
#23366: Workaround for `ValueError: Dependency on app with no migrations` in #22848
may need attention
----------------------------+------------------------------------
Reporter: stevejalim | Owner: yakky
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"f461bc02cbfa7c04748e4b2392586fa3835330b1"]:
{{{
#!CommitTicketReference repository=""
revision="f461bc02cbfa7c04748e4b2392586fa3835330b1"
[1.7.x] Fixed #23366 -- Fixed a crash with the migrate --list command.

Backport of b4bdd5262b18644456d12a00d475adf9897a9255 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23366#comment:15>

Reply all
Reply to author
Forward
0 new messages