From 00f1d2cbdca10277430bb9ec83b04aabd6c1d9c9 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 2 Nov 2023 18:23:16 +0000 Subject: [PATCH] Moving functions inside class. --- .../server/src/sdk/app/tables/migration.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/server/src/sdk/app/tables/migration.ts b/packages/server/src/sdk/app/tables/migration.ts index 5a99d45a6f..718223dbeb 100644 --- a/packages/server/src/sdk/app/tables/migration.ts +++ b/packages/server/src/sdk/app/tables/migration.ts @@ -119,22 +119,6 @@ function getColumnMigrator( throw new BadRequestError(`Unknown migration type`) } -function pickUserTableLinkSide(link: LinkDocument): LinkInfo { - if (link.doc1.tableId === InternalTable.USER_METADATA) { - return link.doc1 - } else { - return link.doc2 - } -} - -function pickOtherTableLinkSide(link: LinkDocument): LinkInfo { - if (link.doc1.tableId === InternalTable.USER_METADATA) { - return link.doc2 - } else { - return link.doc1 - } -} - abstract class UserColumnMigrator implements ColumnMigrator { constructor( protected table: Table, @@ -144,6 +128,22 @@ abstract class UserColumnMigrator implements ColumnMigrator { abstract updateRow(row: Row, linkInfo: LinkInfo): void + pickUserTableLinkSide(link: LinkDocument): LinkInfo { + if (link.doc1.tableId === InternalTable.USER_METADATA) { + return link.doc1 + } else { + return link.doc2 + } + } + + pickOtherTableLinkSide(link: LinkDocument): LinkInfo { + if (link.doc1.tableId === InternalTable.USER_METADATA) { + return link.doc2 + } else { + return link.doc1 + } + } + async doMigration(): Promise { let oldTable = cloneDeep(this.table) let rows = await sdk.rows.fetchRaw(this.table._id!) @@ -154,8 +154,8 @@ abstract class UserColumnMigrator implements ColumnMigrator { let links = await sdk.links.fetchWithDocument(this.table._id!) for (let link of links) { - const userSide = pickUserTableLinkSide(link) - const otherSide = pickOtherTableLinkSide(link) + const userSide = this.pickUserTableLinkSide(link) + const otherSide = this.pickOtherTableLinkSide(link) if ( otherSide.tableId !== this.table._id || otherSide.fieldName !== this.oldColumn.name ||