#29843: Migrations involving permissions (in Meta class of model) are not
applied
immediately
-----------------------------------------+------------------------
Reporter: PetterS | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
We have encountered this problem when deploying our app to a new database.
The easiest way to demonstrate the problem is with this repository:
https://github.com/PetterS/django-demo-app
First clone the repo and execute
{{{
pipenv install
}}}
Then in a clean repository:
{{{
$ python manage.py migrate auth
$ python manage.py migrate myapp
}}}
This fails with "django.contrib.auth.models.DoesNotExist: Permission
matching query does not exist."
Indeed, I can verify that the sqlite database does not contain any custom
permissions. But showmigrations tells me that "0001_initial" and
"0002_auto_20181012_1052" have been applied!
{{{
$ python manage.py showmigrations
...
myapp
[X] 0001_initial
[X] 0002_auto_20181012_1052
[ ] 0003_auto_20181012_1054
}}}
On the other hand, in a clean repository the following succeeds:
{{{
$ python manage.py migrate auth
$ python manage.py migrate myapp 0001_initial
$ python manage.py migrate myapp 0002_auto_20181012_1052
$ python manage.py migrate myapp 0003_auto_20181012_1054
$ python manage.py migrate myapp
}}}
So the result of the migrations adding the permission is not visible until
after the migrate command finished, even if there are other migrations
coming after.
In a clean repository:
{{{
$ python manage.py migrate auth
$ python manage.py migrate myapp 0001_initial
}}}
"can_smell" is now a permission in the DB.
I think this bug is pretty severe, since running migrate on a new DB will
put the database in a state that is not very easy to recover from. The
migrations show as applied, when in fact the permissions have not been
created.
--
Ticket URL: <https://code.djangoproject.com/ticket/29843>
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/050.b519eb95f2952356d05df590a7b9b771%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.