fix(drizzle): generate DB schema syntax is deprecated (#14031)
This commit is contained in:
@@ -118,7 +118,7 @@ export const createSchemaGenerator = ({
|
|||||||
if (table.indexes) {
|
if (table.indexes) {
|
||||||
for (const key in table.indexes) {
|
for (const key in table.indexes) {
|
||||||
const index = table.indexes[key]
|
const index = table.indexes[key]
|
||||||
let indexDeclaration = `${sanitizeObjectKey(key)}: ${index.unique ? 'uniqueIndex' : 'index'}('${index.name}')`
|
let indexDeclaration = `${index.unique ? 'uniqueIndex' : 'index'}('${index.name}')`
|
||||||
indexDeclaration += `.on(${typeof index.on === 'string' ? `${accessProperty('columns', index.on)}` : `${index.on.map((on) => `${accessProperty('columns', on)}`).join(', ')}`}),`
|
indexDeclaration += `.on(${typeof index.on === 'string' ? `${accessProperty('columns', index.on)}` : `${index.on.map((on) => `${accessProperty('columns', on)}`).join(', ')}`}),`
|
||||||
extrasDeclarations.push(indexDeclaration)
|
extrasDeclarations.push(indexDeclaration)
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ export const createSchemaGenerator = ({
|
|||||||
for (const key in table.foreignKeys) {
|
for (const key in table.foreignKeys) {
|
||||||
const foreignKey = table.foreignKeys[key]
|
const foreignKey = table.foreignKeys[key]
|
||||||
|
|
||||||
let foreignKeyDeclaration = `${sanitizeObjectKey(key)}: foreignKey({
|
let foreignKeyDeclaration = `foreignKey({
|
||||||
columns: [${foreignKey.columns.map((col) => `columns['${col}']`).join(', ')}],
|
columns: [${foreignKey.columns.map((col) => `columns['${col}']`).join(', ')}],
|
||||||
foreignColumns: [${foreignKey.foreignColumns.map((col) => `${accessProperty(col.table, col.name)}`).join(', ')}],
|
foreignColumns: [${foreignKey.foreignColumns.map((col) => `${accessProperty(col.table, col.name)}`).join(', ')}],
|
||||||
name: '${foreignKey.name}'
|
name: '${foreignKey.name}'
|
||||||
@@ -166,9 +166,9 @@ ${Object.entries(table.columns)
|
|||||||
.join('\n')}
|
.join('\n')}
|
||||||
}${
|
}${
|
||||||
extrasDeclarations.length
|
extrasDeclarations.length
|
||||||
? `, (columns) => ({
|
? `, (columns) => [
|
||||||
${extrasDeclarations.join('\n ')}
|
${extrasDeclarations.join(' ')}
|
||||||
})`
|
]`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user