All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 45s
Build and Push Docker Images / build-frontend (push) Successful in 25s
Build and Push Docker Images / build-website (push) Successful in 23s
Build and Push Docker Images / build-central-services-api (push) Successful in 23s
Build and Push Docker Images / build-central-services-admin (push) Successful in 24s
Build and Push Docker Images / build-docs (push) Successful in 24s
29 lines
821 B
TypeScript
29 lines
821 B
TypeScript
type QueryClient = {
|
|
query: (query: string, values: unknown[]) => Promise<{ rowCount?: number | null }>
|
|
}
|
|
|
|
type TenantImportData = {
|
|
tenantId: number
|
|
tables: Record<string, Record<string, any>[]>
|
|
}
|
|
|
|
export const restoreImportedTenantNumberRanges = async (
|
|
client: QueryClient,
|
|
exportData: TenantImportData
|
|
) => {
|
|
const tenantRow = (exportData.tables.tenants || []).find(
|
|
(row) => Number(row.id) === Number(exportData.tenantId)
|
|
)
|
|
|
|
if (!tenantRow || tenantRow.numberRanges === null || typeof tenantRow.numberRanges === "undefined") {
|
|
return 0
|
|
}
|
|
|
|
const result = await client.query(
|
|
`update "tenants" set "numberRanges" = $1::jsonb where "id" = $2`,
|
|
[JSON.stringify(tenantRow.numberRanges), exportData.tenantId]
|
|
)
|
|
|
|
return result.rowCount || 0
|
|
}
|