﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30189	sqlmigrate wraps it's outpout in BEGIN/COMMIT even if the database doesn't support transactional DDL	Simon Charette	nobody	"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."	Bug	new	Migrations	dev	Normal				Unreviewed	0	0	0	0	1	0
