Skip to content

Conversation

@autologie
Copy link
Contributor

@autologie autologie commented Dec 16, 2025

Summary

This PR follows up #23032 to introduce foreign key constraint on agentId column in the ChatHub session and message table.

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@autologie autologie changed the title chore(core): Set foreign key constraint on agentId chore(core): Set foreign key constraint on ChatHub agentId Dec 16, 2025
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 41.17647% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ions/common/1765886667897-AddAgentIdForeignKeys.ts 18.18% 9 Missing ⚠️
...ions/sqlite/1765886667897-AddAgentIdForeignKeys.ts 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@currents-bot
Copy link

currents-bot bot commented Dec 16, 2025

E2E Tests: n8n tests passed after 7m 35.6s

🟢 583 · 🔴 0 · ⚪️ 27 · 🟣 4

View Run Details

Run Details

  • Project: n8n

  • Groups: 2

  • Framework: Playwright

  • Run Status: Passed

  • Commit: 43c5d10

  • Spec files: 130

  • Overall tests: 610

  • Duration: 7m 35.6s

  • Parallelization: 9

Groups

GroupId Results Spec Files Progress
multi-main:ui 🟢 526 · 🔴 0 · ⚪️ 27 · 🟣 3 121 / 121
multi-main:ui:isolated 🟢 57 · 🔴 0 · ⚪️ 0 · 🟣 1 9 / 9


This message was posted automatically by currents.dev | Integration Settings

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@autologie autologie marked this pull request as ready for review December 16, 2025 12:42
@autologie autologie requested a review from a team as a code owner December 16, 2025 12:42
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/@n8n/db/src/migrations/common/1765886667897-AddAgentIdForeignKeys.ts">

<violation number="1" location="packages/@n8n/db/src/migrations/common/1765886667897-AddAgentIdForeignKeys.ts:13">
P1: Hardcoded double-quote column escaping (`&quot;agentId&quot;`) will fail on MySQL/MariaDB. Use `escape.columnName(&#39;agentId&#39;)` to ensure cross-database compatibility.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Copy link
Contributor

@guillaumejacquart guillaumejacquart left a comment

Choose a reason for hiding this comment

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

one question

'agentId',
[table.agents, 'id'],
'FK_chat_hub_sessions_agentId',
'SET NULL',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not cascade delete ? Is there a possibility that the agent is deleted and we should still keep the messages ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we want to keep sessions and messages, as these are historical data to browse even when the user doesn't need the agent anymore for new conversations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, seems better & more intuitive than deletion

Copy link
Contributor

@guillaumejacquart guillaumejacquart left a comment

Choose a reason for hiding this comment

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

looks good to me

@autologie autologie merged commit 0ed70e0 into master Dec 16, 2025
43 of 45 checks passed
@autologie autologie deleted the set-agent-id-foreign-key branch December 16, 2025 13:38
@n8n-assistant
Copy link

n8n-assistant bot commented Dec 17, 2025

Got released with [email protected]

yangshoulai pushed a commit to yangshoulai/n8n that referenced this pull request Dec 19, 2025
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