Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7fff6db
feat: add icon to personal and workflow agent
autologie Dec 10, 2025
5187b59
revert workflow agent grouping for now
autologie Dec 10, 2025
ba8bbba
change icon for personal agents
autologie Dec 10, 2025
c90295b
adjust icon size
autologie Dec 10, 2025
645a43f
fix: use agent icon in model selector
autologie Dec 10, 2025
dbb905e
format
autologie Dec 10, 2025
f4c1cd6
design feedback
autologie Dec 11, 2025
3b41d2d
add skeleton
autologie Dec 11, 2025
844e627
refactor
autologie Dec 11, 2025
3e47533
fix: cache icon
autologie Dec 11, 2025
b0a1411
fix: make icon nullable
autologie Dec 11, 2025
6dc84bd
remove projectName for now
autologie Dec 11, 2025
86372ae
fix import order
autologie Dec 11, 2025
cfe2dc9
revert some changes
autologie Dec 11, 2025
84a1650
fix test
autologie Dec 11, 2025
752a1fa
refactor
autologie Dec 11, 2025
a4d7d1b
revert some changes
autologie Dec 11, 2025
bff4a3e
add tests
autologie Dec 11, 2025
5f321be
AI review
autologie Dec 11, 2025
a061d6b
refactor: remove agentIcon column from session table
autologie Dec 12, 2025
198defb
Merge branch 'master' into chat-split-custom-agents
autologie Dec 12, 2025
50614ef
fix: show icon even if agent is no longer available
autologie Dec 12, 2025
6fdb3b0
change agentId type to UUID and add FK constraint
autologie Dec 12, 2025
b6b09a1
Merge branch 'master' into chat-split-custom-agents
autologie Dec 12, 2025
c888ab8
fix error in conflict resolution
autologie Dec 12, 2025
8327d14
Merge branch 'master' into chat-split-custom-agents
Cadiac Dec 14, 2025
9e4a2c0
add FK constraint on agentId column in chat messages table
autologie Dec 15, 2025
181907c
add explicit name to FKs
autologie Dec 15, 2025
1840e1d
update migration timestamp
autologie Dec 15, 2025
7449aff
feat: add tooltip in model selector
autologie Dec 15, 2025
ab79ad0
exclude FKs from migration
autologie Dec 15, 2025
bd4daeb
refactor
autologie Dec 15, 2025
f40df38
Merge branch 'master' into chat-split-custom-agents
autologie Dec 15, 2025
41cced4
Merge branch 'master' into chat-split-custom-agents
Cadiac Dec 15, 2025
c6e0246
fix: add back migration for updating column type
autologie Dec 15, 2025
752c6f2
Merge branch 'master' into chat-split-custom-agents
autologie Dec 15, 2025
328d3c1
lint
autologie Dec 15, 2025
2f6ce74
fix type
autologie Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change agentId type to UUID and add FK constraint
  • Loading branch information
autologie committed Dec 12, 2025
commit 6fdb3b0b98ad455f9480b1298147feb303dc9717
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
import type { MigrationContext, ReversibleMigration } from '../migration-types';

const tableName = 'chat_hub_agents';
const table = {
agents: 'chat_hub_agents',
sessions: 'chat_hub_sessions',
} as const;

export class AddIconToAgentTable1765361177092 implements ReversibleMigration {
async up({
schemaBuilder: { addColumns, column },
schemaBuilder: { addColumns, column, addForeignKey },
runQuery,
isMysql,
isPostgres,
escape,
}: MigrationContext) {
const escapedTableName = escape.tableName(tableName);
const escapedIdColumn = escape.columnName('id');

// Add icon column to agents table (nullable)
await addColumns(tableName, [column('icon').json]);
await addColumns(table.agents, [column('icon').json]);

// Change agents.id from UUID to varchar to match foreign key references
// For PostgreSQL: convert agentId from varchar(36) to uuid to match agents.id type
if (isPostgres) {
await runQuery(
`ALTER TABLE ${escapedTableName} ALTER COLUMN ${escapedIdColumn} TYPE VARCHAR`,
`ALTER TABLE ${escape.tableName(table.sessions)} ALTER COLUMN "agentId" TYPE uuid USING "agentId"::uuid`,
);
} else if (isMysql) {
await runQuery(`ALTER TABLE ${escapedTableName} MODIFY COLUMN \`id\` VARCHAR(255)`);
}

// Clean up orphaned agentId references before adding foreign key constraint
await runQuery(
`UPDATE ${escape.tableName(table.sessions)} SET "agentId" = NULL WHERE "agentId" IS NOT NULL AND "agentId" NOT IN (SELECT id FROM ${escape.tableName(table.agents)})`,
);

// Add foreign key constraint for agentId in sessions table
await addForeignKey(table.sessions, 'agentId', [table.agents, 'id'], undefined, 'SET NULL');
}

async down({
schemaBuilder: { dropColumns },
schemaBuilder: { dropColumns, dropForeignKey },
runQuery,
isMysql,
isPostgres,
escape,
}: MigrationContext) {
const escapedTableName = escape.tableName(tableName);
const escapedIdColumn = escape.columnName('id');
// Drop foreign key constraint
await dropForeignKey(table.sessions, 'agentId', [table.agents, 'id']);

// For PostgreSQL: revert agentId from uuid back to varchar(36)
if (isPostgres) {
await runQuery(
`ALTER TABLE ${escapedTableName} ALTER COLUMN ${escapedIdColumn} TYPE UUID USING ${escapedIdColumn}::UUID`,
`ALTER TABLE ${escape.tableName(table.sessions)} ALTER COLUMN "agentId" TYPE varchar(36)`,
);
} else if (isMysql) {
await runQuery(`ALTER TABLE ${escapedTableName} MODIFY COLUMN \`id\` CHAR(36)`);
}

await dropColumns(tableName, ['icon']);
// Drop icon column
await dropColumns(table.agents, ['icon']);
}
}
9 changes: 6 additions & 3 deletions packages/cli/src/modules/chat-hub/chat-hub-agent.entity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { ChatHubLLMProvider, AgentIconOrEmoji } from '@n8n/api-types';
import { WithTimestampsAndStringId, User, CredentialsEntity, JsonColumn } from '@n8n/db';
import { Column, Entity, ManyToOne, JoinColumn } from '@n8n/typeorm';
import { User, CredentialsEntity, JsonColumn, WithTimestamps } from '@n8n/db';
import { Column, Entity, ManyToOne, JoinColumn, PrimaryGeneratedColumn } from '@n8n/typeorm';
import { INode } from 'n8n-workflow';

@Entity({ name: 'chat_hub_agents' })
export class ChatHubAgent extends WithTimestampsAndStringId {
export class ChatHubAgent extends WithTimestamps {
@PrimaryGeneratedColumn('uuid')
id: string;

/**
* The name of the chat agent.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class ChatHubSession extends WithTimestamps {
* ID of the custom agent to use (if applicable).
* Only set when provider is 'custom-agent'.
*/
@Column({ type: 'varchar', length: 36, nullable: true })
@Column({ type: 'uuid', nullable: true })
agentId: string | null;

/**
Expand Down