#24630: Misleading/incorrect docs about RunPython and transactions
-------------------------------------+-------------------------------------
     Reporter:  lucacorti            |                    Owner:
                                     |  priidukull
         Type:  Bug                  |                   Status:  new
    Component:  Documentation        |                  Version:  1.8
     Severity:  Release blocker      |               Resolution:
     Keywords:  uuidfiled            |             Triage Stage:  Accepted
  migrations                         |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * stage:  Unreviewed => Accepted
 * component:  Migrations => Documentation
 * severity:  Normal => Release blocker


Comment:

 It seems to me that the documentation that says, "By default, RunPython
 will run its contents inside a transaction" is misleading (added in
 5a917cfef319df33ca30a3b27bd0b0533b8e63bb).

 Each *migration* is run in its own transaction (if the database backend
 has `can_rollback_ddl = True`) because we use
 
[https://github.com/django/django/blob/1418f7530455abf3e6f743164ae15ee6b2566a3c/django/db/migrations/executor.py#L122-L128
 a SchemaEditor context manager] when applying each migration, which
 
[https://github.com/django/django/commit/e74d2183c28467aefc0b87e3fa6d405dbfdea82c
 creates a transaction].

 I'm not sure we can make any changes code-wise to support mixing schema
 changes and RunPython operations in the same migration, but we should
 correct the documentation for current version of Django anyway.

 Docs to fix:
 * The second example migration needs to be split into at least two
 migrations. https://docs.djangoproject.com/en/1.8/howto/writing-migrations
 /#migrations-that-add-unique-fields
 * "By default, RunPython will run its contents..."
 https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runpython

--
Ticket URL: <https://code.djangoproject.com/ticket/24630#comment:10>
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/067.dc06c41c58540e557bc7111924d1bdce%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to