Skip to content

Commit ef57d24

Browse files
authored
fix(drizzle): generate DB schema syntax is deprecated (#14031)
1 parent 9d6cae0 commit ef57d24

File tree

2 files changed

+1671
-456
lines changed

2 files changed

+1671
-456
lines changed

packages/drizzle/src/utilities/createSchemaGenerator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const createSchemaGenerator = ({
118118
if (table.indexes) {
119119
for (const key in table.indexes) {
120120
const index = table.indexes[key]
121-
let indexDeclaration = `${sanitizeObjectKey(key)}: ${index.unique ? 'uniqueIndex' : 'index'}('${index.name}')`
121+
let indexDeclaration = `${index.unique ? 'uniqueIndex' : 'index'}('${index.name}')`
122122
indexDeclaration += `.on(${typeof index.on === 'string' ? `${accessProperty('columns', index.on)}` : `${index.on.map((on) => `${accessProperty('columns', on)}`).join(', ')}`}),`
123123
extrasDeclarations.push(indexDeclaration)
124124
}
@@ -128,7 +128,7 @@ export const createSchemaGenerator = ({
128128
for (const key in table.foreignKeys) {
129129
const foreignKey = table.foreignKeys[key]
130130

131-
let foreignKeyDeclaration = `${sanitizeObjectKey(key)}: foreignKey({
131+
let foreignKeyDeclaration = `foreignKey({
132132
columns: [${foreignKey.columns.map((col) => `columns['${col}']`).join(', ')}],
133133
foreignColumns: [${foreignKey.foreignColumns.map((col) => `${accessProperty(col.table, col.name)}`).join(', ')}],
134134
name: '${foreignKey.name}'
@@ -166,9 +166,9 @@ ${Object.entries(table.columns)
166166
.join('\n')}
167167
}${
168168
extrasDeclarations.length
169-
? `, (columns) => ({
170-
${extrasDeclarations.join('\n ')}
171-
})`
169+
? `, (columns) => [
170+
${extrasDeclarations.join(' ')}
171+
]`
172172
: ''
173173
}
174174
)

0 commit comments

Comments
 (0)