Fix types

This commit is contained in:
Adria Navarro 2023-10-05 12:06:42 +02:00
parent fe6535a65f
commit dd373cd5e9
1 changed files with 8 additions and 6 deletions

View File

@ -15,10 +15,11 @@ function checkForeignKeysAreAutoColumns(datasource: Datasource) {
// make sure all foreign key columns are marked as auto columns // make sure all foreign key columns are marked as auto columns
const foreignKeys: { tableId: string; key: string }[] = [] const foreignKeys: { tableId: string; key: string }[] = []
for (let table of tables) { for (let table of tables) {
const relationships = Object.values(table.schema).filter( Object.values(table.schema).forEach(column => {
column => column.type === FieldType.LINK if (column.type !== FieldType.LINK) {
) return
relationships.forEach(relationship => { }
const relationship = column
if (relationship.relationshipType === RelationshipType.MANY_TO_MANY) { if (relationship.relationshipType === RelationshipType.MANY_TO_MANY) {
const tableId = relationship.through! const tableId = relationship.through!
foreignKeys.push({ key: relationship.throughTo!, tableId }) foreignKeys.push({ key: relationship.throughTo!, tableId })
@ -36,8 +37,9 @@ function checkForeignKeysAreAutoColumns(datasource: Datasource) {
} }
// now make sure schemas are all accurate // now make sure schemas are all accurate
for (let table of tables) { for (const table of tables) {
for (let column of Object.values(table.schema)) { for (let column of Object.values(table.schema) as any[]) {
// TODO: any[]
const shouldBeForeign = foreignKeys.find( const shouldBeForeign = foreignKeys.find(
options => options.tableId === table._id && options.key === column.name options => options.tableId === table._id && options.key === column.name
) )