mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-26 04:23:58 +03:00
UBERF-5321: Fix workspace CLI upgrade (#4534)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
99564ddcb7
commit
68d7a5b5b7
@ -17,7 +17,6 @@
|
||||
import {
|
||||
ACCOUNT_DB,
|
||||
assignWorkspace,
|
||||
ClientWorkspaceInfo,
|
||||
confirmEmail,
|
||||
createAcc,
|
||||
createWorkspace,
|
||||
@ -30,7 +29,8 @@ import {
|
||||
replacePassword,
|
||||
setAccountAdmin,
|
||||
setRole,
|
||||
upgradeWorkspace
|
||||
upgradeWorkspace,
|
||||
WorkspaceInfo
|
||||
} from '@hcengineering/account'
|
||||
import { setMetadata } from '@hcengineering/platform'
|
||||
import {
|
||||
@ -276,14 +276,23 @@ export function devTool (
|
||||
const workspaces = await listWorkspaces(db, productId)
|
||||
const withError: string[] = []
|
||||
|
||||
async function _upgradeWorkspace (ws: ClientWorkspaceInfo): Promise<void> {
|
||||
async function _upgradeWorkspace (ws: WorkspaceInfo): Promise<void> {
|
||||
const t = Date.now()
|
||||
const logger = cmd.console
|
||||
? consoleModelLogger
|
||||
: new FileModelLogger(path.join(cmd.logs, `${ws.workspace}.log`))
|
||||
console.log('---UPGRADING----', ws.workspace, !cmd.console ? (logger as FileModelLogger).file : '')
|
||||
try {
|
||||
await upgradeWorkspace(version, txes, migrateOperations, productId, db, ws.workspace, logger, cmd.force)
|
||||
await upgradeWorkspace(
|
||||
version,
|
||||
txes,
|
||||
migrateOperations,
|
||||
productId,
|
||||
db,
|
||||
ws.workspaceUrl ?? ws.workspace,
|
||||
logger,
|
||||
cmd.force
|
||||
)
|
||||
console.log('---UPGRADING-DONE----', ws.workspace, Date.now() - t)
|
||||
} catch (err: any) {
|
||||
withError.push(ws.workspace)
|
||||
|
@ -576,7 +576,7 @@ export async function createAccount (
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function listWorkspaces (db: Db, productId: string): Promise<ClientWorkspaceInfo[]> {
|
||||
export async function listWorkspaces (db: Db, productId: string): Promise<WorkspaceInfo[]> {
|
||||
return (await db.collection<Workspace>(WORKSPACE_COLLECTION).find(withProductId(productId, {})).toArray())
|
||||
.map((it) => ({ ...it, productId }))
|
||||
.filter((it) => it.disabled !== true)
|
||||
@ -750,7 +750,7 @@ export async function upgradeWorkspace (
|
||||
}
|
||||
const versionStr = versionToString(version)
|
||||
|
||||
const currentVersion = await db.collection<Workspace>(WORKSPACE_COLLECTION).findOne({ workspace: workspaceUrl })
|
||||
const currentVersion = await db.collection<Workspace>(WORKSPACE_COLLECTION).findOne({ workspace: ws.workspace })
|
||||
console.log(
|
||||
`${forceUpdate ? 'force-' : ''}upgrade from "${
|
||||
currentVersion?.version !== undefined ? versionToString(currentVersion.version) : ''
|
||||
@ -761,13 +761,13 @@ export async function upgradeWorkspace (
|
||||
return versionStr
|
||||
}
|
||||
await db.collection(WORKSPACE_COLLECTION).updateOne(
|
||||
{ workspace: workspaceUrl },
|
||||
{ workspace: ws.workspace },
|
||||
{
|
||||
$set: { version }
|
||||
}
|
||||
)
|
||||
await (
|
||||
await upgradeModel(getTransactor(), getWorkspaceId(workspaceUrl, productId), txes, migrationOperation, logger)
|
||||
await upgradeModel(getTransactor(), getWorkspaceId(ws.workspace, productId), txes, migrationOperation, logger)
|
||||
).close()
|
||||
return versionStr
|
||||
}
|
||||
@ -881,7 +881,7 @@ export type ClientWorkspaceInfo = Omit<Workspace, '_id' | 'accounts' | 'workspac
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type WorkspaceInfo = Omit<Workspace, '_id' | 'accounts' | 'workspaceUrl'>
|
||||
export type WorkspaceInfo = Omit<Workspace, '_id' | 'accounts'>
|
||||
|
||||
function mapToClientWorkspace (ws: Workspace): ClientWorkspaceInfo {
|
||||
const { _id, accounts, ...data } = ws
|
||||
|
Loading…
Reference in New Issue
Block a user