Skip to content
Open
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions packages/drizzle/src/schema/traverseFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,13 @@ export const traverseFields = ({
},
}

const baseForeignKeys: Record<string, RawForeignKey> = {
_parentIdFk: {
// Skip creating a parent_id foreign key for blocks that are shared across collections (have a custom dbName)
const hasCustomDbName = block.dbName !== undefined && block.dbName !== null
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Consider using a more concise nullish coalescing check. The condition can be simplified to block.dbName != null which checks for both undefined and null in a single comparison.

Suggested change
const hasCustomDbName = block.dbName !== undefined && block.dbName !== null
const hasCustomDbName = block.dbName != null

Copilot uses AI. Check for mistakes.
const shouldSkipForeignKey = hasCustomDbName

const baseForeignKeys: Record<string, RawForeignKey> = {}
if (!shouldSkipForeignKey) {
baseForeignKeys._parentIdFk = {
name: `${blockTableName}_parent_id_fk`,
columns: ['_parentID'],
foreignColumns: [
Expand All @@ -461,7 +466,7 @@ export const traverseFields = ({
},
],
onDelete: 'cascade',
},
}
}

const isLocalized =
Expand Down
Loading