-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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): Add missing primary key to execution annotation tags table #11168
fix(core): Add missing primary key to execution annotation tags table #11168
Conversation
Since this PR adds another migration on top of the original migration that introduced the table (1724753530828-CreateExecutionAnnotationTables), will this PR actually fix the migration blocker for users that don't have access to the |
97387ae
to
30c8dcf
Compare
@csuermann you are right, adding another migration will not help those who can not disable
For the majority of users, who already have the initial migration applied, the new migration will add missing PK. What do you think? |
That should solve it! Thanks! |
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.
Looks good from my side. I assume you tested both these scenarios:
- migrating to an empty DB
- migrating to a DB which has all except the new migration
.../src/databases/migrations/common/1728396464278-AddMissingPrimaryKeyOnAnnotationTagMapping.ts
Outdated
Show resolved
Hide resolved
.../src/databases/migrations/sqlite/1728396464278-AddMissingPrimaryKeyOnAnnotationTagMapping.ts
Outdated
Show resolved
Hide resolved
await dropIndex(`${annotationTagMappingsTableName}_tmp`, ['tagId'], { | ||
customIndexName: 'IDX_a3697779b366e131b2bbdae297', | ||
}); | ||
await dropIndex(`${annotationTagMappingsTableName}_tmp`, ['annotationId'], { | ||
customIndexName: 'IDX_c1519757391996eb06064f0e7c', | ||
}); |
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.
Do we need to drop these if the tmp table gets dropped at the end? Does that also drop these indexes?
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.
Yes, otherwise it fails on creating new table, as indexes with these names are already exist.
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.
You could give the new indexes custom names to prevent this as well.
I had to do this here as well:
n8n/packages/cli/src/databases/migrations/common/1720101653148-AddConstraintToExecutionMetadata.ts
Lines 83 to 87 in 2e6b03b
// INFO: The PK names that TypeORM creates are predictable and thus it | |
// will create a PK name which already exists in the current | |
// execution_metadata table. That's why we have to randomize the PK name | |
// here. | |
column('id').int.notNull.primaryWithName(nanoid()).autoGenerate, |
b5ac53d
to
ea49d5e
Compare
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.
LGTM 🚀
✅ All Cypress E2E specs passed |
n8n Run #7428
Run Properties:
|
Project |
n8n
|
Run status |
Passed #7428
|
Run duration | 04m 22s |
Commit |
ea49d5e631: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 burivuhster 🗃️ e2e/*
|
Committer | Eugene Molodkin |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
3
|
Pending |
0
|
Skipped |
0
|
Passing |
438
|
Summary
This PR adds missing composite primary index to the table
execution_annotation_tags
.It uses typeorm method for MySQL and PostgreSQL, but since sqlite does not support adding primary keys to existing tables, it creates a new table and copy existing data.
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)