Skip to content

Add transaction mode to migration generation - #369

Open
samdark wants to merge 4 commits into
masterfrom
issue-367-transaction-mode
Open

samdark wants to merge 4 commits into
masterfrom
issue-367-transaction-mode

Conversation

@samdark

@samdark samdark commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

migrate:create has no transaction-mode override, and its templates have different defaults. Add --transaction / --no-transaction and a nullable newMigrationTransactional setting for Yii Console, standalone usage, and named databases. CLI overrides take precedence over configuration; omitting both preserves each template's existing behavior.

Update all built-in templates and expose the resolved nullable mode to custom templates. Document configuration, precedence, and custom-template behavior.

Fixes #367.

Q A
Is bugfix? ❌
New feature? ✔️
Breaks BC? ❌

Copilot AI balanced review requested due to automatic review settings October 14, 2026 21:12
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.39%. Comparing base (caa0741) to head (a09ea3a).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #369      +/-   ##
============================================
+ Coverage     97.36%   97.39%   +0.03%     
  Complexity      373      373              
============================================
  Files            25       25              
  Lines          1176     1192      +16     
============================================
+ Hits           1145     1161      +16     
  Misses           31       31              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samdark
samdark marked this pull request as draft October 14, 2026 21:18
Copilot stopped reviewing on behalf of samdark due to an error October 14, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

5 open findings
What changed in this PR

Adds configurable transaction mode for generated migrations, including CLI overrides and documentation.

Changes:

  • Added newMigrationTransactional configuration (nullable) and wired it through DI / DatabaseSet.
  • Added --transaction/--no-transaction option to migrate:create and passed it through to templates.
  • Updated built-in templates, tests, and docs to support and verify transactional-mode generation.
File Description
tests/​Support/​Templates/​transactionMode.php Adds a minimal template to assert the passed transaction mode.
tests/​Support/​Helper/​ContainerHelper.php Passes newMigrationTransactional into CreateService in test container wiring.
tests/​Support/​Helper/​ContainerConfig.php Adds newMigrationTransactional test configuration knob.
tests/​Migration/​ConfigTest.php Adds config-level coverage for default vs per-db transactional mode.
tests/​Migration/​BinTest.php Adds CLI-level coverage for --transaction/--no-transaction.
tests/​Driver/​Sqlite/​DatabaseCommandsTest.php Adds coverage for named database set transaction mode and CLI overrides.
tests/​Driver/​Sqlite/​CreateCommandTest.php Adds sqlite-level tests for defaults, config, and overrides; ensures overrides don’t leak.
tests/​Common/​Service/​Generate/​AbstractCreateServiceTest.php Adds generator/service-level matrix tests across commands and modes.
src/​Service/​Generate/​CreateService.php Adds configured default transactional mode + per-run override passed into templates.
src/​DatabaseSetRegistry.php Wires database-set transactional config into created CreateService.
src/​DatabaseSet.php Adds newMigrationTransactional to database set configuration.
src/​Command/​CreateCommand.php Adds --transaction/--no-transaction option and forwards it to generator.
resources/​views/​migration.php Makes “create” template transactional behavior configurable via $transactional.
resources/​views/​dropTableMigration.php Makes drop-table template transactional behavior configurable via $transactional.
resources/​views/​dropColumnMigration.php Makes drop-column template transactional behavior configurable via $transactional.
resources/​views/​createTableMigration.php Makes create-table template transactional behavior configurable via $transactional.
resources/​views/​addColumnMigration.php Makes add-column template transactional behavior configurable via $transactional.
docs/​guide/​en/​transactional-migrations.md New guide explaining transactional migrations and configuration/overrides.
docs/​guide/​en/​README.md Adds link to new transactional migrations guide.
config/​params.php Introduces newMigrationTransactional parameter with default null.
config/​di-console.php Wires newMigrationTransactional param into CreateService via DI.
bin/​yii-db-migration.php Adds standalone config entry for newMigrationTransactional.
bin/​yii-db-migration Passes newMigrationTransactional into standalone CreateService.
README.md Documents CLI flags and links to the new guide.
CHANGELOG.md Notes the new transactional generation feature.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/guide/en/transactional-migrations.md Outdated
Comment thread tests/Driver/Sqlite/CreateCommandTest.php Outdated
Comment thread resources/views/dropColumnMigration.php
Comment thread resources/views/dropColumnMigration.php
Comment thread resources/views/dropColumnMigration.php
@samdark
samdark marked this pull request as ready for review October 14, 2026 22:21
@samdark
samdark requested a review from a team October 14, 2026 22:22
@vjik

vjik commented Oct 16, 2026

Copy link
Copy Markdown
Member

@samdark Resolve conflicts, please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create migration with transaction mode

3 participants