Skip to content

fix(MySQL): add an auto-increment column together with its index - #279

Open
roxblnfk wants to merge 2 commits into
2.xfrom
fix/mysql-add-autoincrement-column
Open

roxblnfk wants to merge 2 commits into
2.xfrom
fix/mysql-add-autoincrement-column

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Oct 5, 2026

Copy link
Copy Markdown
Member

🔍 What was changed

  • An autoIncrement: true column added to an existing MySQL table is now created in the same ALTER TABLE as the indexes that cover it. Before, the index was created afterwards and the column failed with error 1075.
  • Such a column without an index fails with the same SchemaException as on table creation (fix(MySQL): keep auto-increment columns out of the primary key #275), before the column is added.
  • All other added columns and indexes go through the usual separate statements.

Review notes

  • Turning an existing column into an AUTO_INCREMENT one (ALTER … CHANGE) together with a new index still runs the index afterwards. That path is unchanged here.

Checklist

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
MySQL rejects an AUTO_INCREMENT column without a key (error 1075), so adding one to an existing table and creating its index afterwards always failed. The column and the indexes covering it now go into a single ALTER TABLE; a column with no index fails with the same SchemaException as on table creation, before the column is added.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk requested review from a team as code owners October 5, 2026 13:44
@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.73%. Comparing base (73a8306) to head (1c9e9d2).

Additional details and impacted files
@@            Coverage Diff            @@
##                2.x     #279   +/-   ##
=========================================
  Coverage     95.72%   95.73%           
- Complexity     2246     2252    +6     
=========================================
  Files           142      142           
  Lines          6384     6397   +13     
=========================================
+ Hits           6111     6124   +13     
  Misses          273      273           

☔ 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.

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.

1 participant