#28463: Custom migrations that create a postgres role run against the production
database during tests (postgres 9.6)
---------------------------------------------+------------------------
               Reporter:  Simon Tomlinson    |          Owner:  nobody
                   Type:  Bug                |         Status:  new
              Component:  Testing framework  |        Version:  1.11
               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                  |
---------------------------------------------+------------------------
 Creating a custom migration that uses `migrations.RunSQL` to create a new
 postgres role and then running tests using `python manage.py test` creates
 the role in the real postgres server (when running postgres 9.6).

 This doesn't happen with other custom sql, such as creating a type, which
 I found very odd.

 Attached is a django project configured to connect to a postgres database
 running on localhost:5432, with a "postgres" user with no password and a
 postgres database. It contains an app called "app" with a single migration
 that executes `CREATE ROLE test_role`.

 Run `python  manage.py test` and then inspect the database to reproduce.
 The role `test_role` should exist (list it with `\du` in psql).
 Alternatively, run `python manage.py test` twice. It will crash the second
 time because the role already exists from the first run.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28463>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.f137e01eeb29f6bb31c47cbc3c9417f7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to