#30189: sqlmigrate wraps it's outpout in BEGIN/COMMIT even if the database 
doesn't
support transactional DDL
--------------------------------+--------------------------------------
     Reporter:  Simon Charette  |                    Owner:  nobody
         Type:  Bug             |                   Status:  new
    Component:  Migrations      |                  Version:  master
     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
--------------------------------+--------------------------------------
Description changed by Simon Charette:

Old description:

> The migration executor only adds the outer `BEGIN`/`COMMIT`
> [https://github.com/django/django/blob/edec11ce86a1a0d9e4c5a2a0df6acaf655041c24/django/db/migrations/executor.py#L243-L247
> if the migration is atomic] and
> [https://github.com/django/django/blob/edec11ce86a1a0d9e4c5a2a0df6acaf655041c24/django/db/backends/base/schema.py#L97
> the schema editor can rollback DDL] but the current `sqlmigrate` logic
> only takes `migration.atomic` into consideration.
>
> The issue change be addressed by
>
> 1. Changing `sqlmigrate`
> [https://github.com/django/django/blob/edec11ce86a1a0d9e4c5a2a0df6acaf655041c24/django/core/management/commands/sqlmigrate.py#L59
> assignment] of `self.output_transaction` to consider
> `connection.features.can_rollback_ddl` as well.
> 2. Adding a test in `tests/migrations/test_commands.py` based on
> [https://github.com/django/django/blob/2bd8df243ac6fc35e58c9fe90b20c9e42519a5ac/tests/migrations/test_commands.py#L606-L617
> an existing test for non-atomic migrations] that mocks
> `connection.features.can_rollback_ddl` to `False` instead of overdidding
> `MIGRATION_MODULES` to point to a non-atomic migration.
>
> I marked the ticket as ''easy picking'' because I included the above
> guidelines but feel free to uncheck it if you deem it inappropriate.

New description:

 The migration executor only adds the outer `BEGIN`/`COMMIT`
 
[https://github.com/django/django/blob/edec11ce86a1a0d9e4c5a2a0df6acaf655041c24/django/db/migrations/executor.py#L243-L247
 if the migration is atomic] and
 
[https://github.com/django/django/blob/edec11ce86a1a0d9e4c5a2a0df6acaf655041c24/django/db/backends/base/schema.py#L97
 the schema editor can rollback DDL] but the current `sqlmigrate` logic
 only takes `migration.atomic` into consideration.

 The issue can be addressed by

 1. Changing `sqlmigrate`
 
[https://github.com/django/django/blob/edec11ce86a1a0d9e4c5a2a0df6acaf655041c24/django/core/management/commands/sqlmigrate.py#L59
 assignment] of `self.output_transaction` to consider
 `connection.features.can_rollback_ddl` as well.
 2. Adding a test in `tests/migrations/test_commands.py` based on
 
[https://github.com/django/django/blob/2bd8df243ac6fc35e58c9fe90b20c9e42519a5ac/tests/migrations/test_commands.py#L606-L617
 an existing test for non-atomic migrations] that mocks
 `connection.features.can_rollback_ddl` to `False` instead of overdidding
 `MIGRATION_MODULES` to point to a non-atomic migration.

 I marked the ticket as ''easy picking'' because I included the above
 guidelines but feel free to uncheck it if you deem it inappropriate.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30189#comment:1>
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.90dfb95940f640d8acaa08be352861e4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to