-
Notifications
You must be signed in to change notification settings - Fork 13.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): Fix DB migrations for MySQL #13261
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing this and adding the new targets to the DB tests ❤️
n8n
|
Project |
n8n
|
Branch Review |
ai-644-failing-mysql-db-migration
|
Run status |
|
Run duration | 04m 27s |
Commit |
|
Committer | Eugene Molodkin |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
1
|
|
5
|
|
0
|
|
436
|
View all changes introduced in this branch ↗︎ |
✅ All Cypress E2E specs passed |
@tomi I was running some tests locally and found there are still cases, where primary key fix might not be applied (when all previous migrations were applied "successfully" before patch). I added a separate conditional migration to account for that. Tested on mysql 8.0.29 and 8.4, mariadb 10.5, each for both applying all migrations at once (same as in CI pipeline), and applying migrations from master branch first, then switching to this branch and applying all the fixes. |
✅ All Cypress E2E specs passed |
Summary
This PR address couple of DB migration issues, preventing n8n to start when using MySQL as a database
Column check constraint
Migration
AddStatsColumnsToTestRun1736172058779
introduced some column check constraints, but referencing other columns in check condition of a column check constraint is not supported by MySQL (checked on8.0.29
,8.0.41
,8.4.4
).Solution
As those stats columns are soon to be removed anyway, created a separate migration file for MySQL under same migration name, without the check constraints. This change will not affect existing instances where the migration applied successfully, but only instances powered by MySQL, where this migration could not be applied.
Incomplete migration of PK type
The migration
MigrateTestDefinitionKeyToString1731582748663
implementation for MySQL was incomplete. Although it run successfully, the queries for assigning new Primary Key and deleting temporary one was missing. This left the tabletest_definition
in an inconsistent state (no PK), which prevented the next migrationCreateTestMetricTable1732271325258
from running properly on MySQL8.4.4
:Solution
Missing operations were added to the
MigrateTestDefinitionKeyToString1731582748663
migration.For those instances where the incomplete migration was already applied, the same operations were added to the subsequent migration
CreateTestMetricTable1732271325258
conditionally.Also
FixTestDefinitionPrimaryKey1739873751194
migration was added to fix the primary column if it has not been fixed yet by the patchedMigrateTestDefinitionKeyToString1731582748663
orCreateTestMetricTable1732271325258
migrations.Added DB tests
To avoid issues like this in future, a new job for running tests using MySQL was added to a CI config.
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)