mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-10 03:37:43 +02:00
UBERF-5986: Upgrade fixes (#4957)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -604,6 +604,27 @@ export async function listWorkspaces (db: Db, productId: string): Promise<Worksp
|
||||
.map(trimWorkspaceInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function listWorkspacesRaw (db: Db, productId: string): Promise<Workspace[]> {
|
||||
return (await db.collection<Workspace>(WORKSPACE_COLLECTION).find(withProductId(productId, {})).toArray()).map(
|
||||
(it) => ({ ...it, productId })
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function updateWorkspace (
|
||||
db: Db,
|
||||
productId: string,
|
||||
info: Workspace,
|
||||
ops: Partial<Workspace>
|
||||
): Promise<void> {
|
||||
await db.collection<Workspace>(WORKSPACE_COLLECTION).updateOne({ _id: info._id }, { $set: { ...info, ...ops } })
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@@ -772,7 +793,7 @@ export async function upgradeWorkspace (
|
||||
const versionStr = versionToString(version)
|
||||
|
||||
console.log(
|
||||
`${forceUpdate ? 'force-' : ''}upgrade from "${
|
||||
`${workspaceUrl} - ${forceUpdate ? 'force-' : ''}upgrade from "${
|
||||
ws?.version !== undefined ? versionToString(ws.version) : ''
|
||||
}" to "${versionStr}"`
|
||||
)
|
||||
|
||||
@@ -183,7 +183,9 @@ export class MigrateClientImpl implements MigrationClient {
|
||||
|
||||
async create<T extends Doc>(domain: Domain, doc: T | T[]): Promise<void> {
|
||||
if (Array.isArray(doc)) {
|
||||
await this.db.collection(domain).insertMany(doc as Document[])
|
||||
if (doc.length > 0) {
|
||||
await this.db.collection(domain).insertMany(doc as Document[])
|
||||
}
|
||||
} else {
|
||||
await this.db.collection(domain).insertOne(doc as Document)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user