Skip to content

Add ALGORITHM/LOCK support to Index operations#1057

Open
jamisonbryant wants to merge 3 commits into5.xfrom
feature/index-algorithm-lock-options
Open

Add ALGORITHM/LOCK support to Index operations#1057
jamisonbryant wants to merge 3 commits into5.xfrom
feature/index-algorithm-lock-options

Conversation

@jamisonbryant
Copy link
Copy Markdown
Contributor

@jamisonbryant jamisonbryant commented Mar 23, 2026

Summary

Extends the ALGORITHM and LOCK clause support added in #955 (for Column operations) to also cover Index operations. This allows addIndex to pass algorithm and lock options through the fluent API on MySQL.

Usage:

$table->addIndex('email', [
    'algorithm' => MysqlAdapter::ALGORITHM_INPLACE,
    'lock' => MysqlAdapter::LOCK_NONE,
])->update();

Changes:

  • Add algorithm and lock properties, getters/setters, and valid options to Index class
  • Wire algorithm/lock from Index through getAddIndexInstructions() in MysqlAdapter
  • Handle FULLTEXT indexes which use post-steps (algorithm/lock clause inlined into the SQL)
  • Add 9 tests mirroring the Column algorithm/lock test coverage

Note: Drop index operations are out of scope, matching Column behavior where getDropColumnInstructions also does not support algorithm/lock (the method signature only receives string parameters, not the object).

Test plan

  • PHPStan passes (composer stan)
  • New Index algorithm/lock tests pass against MySQL 8.4
  • Existing Column algorithm/lock tests still pass (no regression)
  • CI passes on all PHP versions

Extend the ALGORITHM and LOCK clause support added in PR #955 for
Column operations to also cover Index operations. This allows addIndex
to pass algorithm and lock options through the fluent API on MySQL.

Changes:
- Add algorithm/lock properties, getters/setters to Index class
- Wire algorithm/lock through getAddIndexInstructions in MysqlAdapter
- Handle FULLTEXT indexes which use post-steps (inline the clause)
- Add 9 tests mirroring the Column algorithm/lock test coverage
@jamisonbryant jamisonbryant self-assigned this Mar 23, 2026
@jamisonbryant jamisonbryant marked this pull request as ready for review March 23, 2026 21:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extends MySQL ALTER TABLE ... ALGORITHM=... / LOCK=... support from column operations to index operations by adding algorithm/lock options to the Index value object and wiring them through MysqlAdapter alter-instruction generation (including FULLTEXT special-casing).

Changes:

  • Add algorithm and lock properties + getters/setters + option mapping to src/Db/Table/Index.php.
  • Pass index algorithm/lock options through MysqlAdapter::getAddIndexInstructions() (including FULLTEXT post-step handling).
  • Add MySQL adapter integration tests for index algorithm/lock behaviors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
tests/TestCase/Db/Adapter/MysqlAdapterTest.php Adds new MySQL integration tests for index algorithm/lock options and batched behavior.
src/Db/Table/Index.php Introduces algorithm/lock as supported index options via new properties and setters/getters.
src/Db/Adapter/MysqlAdapter.php Wires algorithm/lock from Index into AlterInstructions and FULLTEXT SQL generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Verify that ALGORITHM and LOCK clauses appear in generated SQL
using verbose logging, and exercise the fluent Column/Index
builder path for both column and index operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants