uberf-6537: fix teamspace creation (#5354)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-04-15 08:16:35 +04:00 committed by GitHub
parent bccf97eeb7
commit c12327867c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 18 deletions

View File

@ -314,15 +314,18 @@ export const documentOperation: MigrateOperation = {
},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const tx = new TxOperations(client, core.account.System)
await tryUpgrade(client, documentId, [
{
state: 'u-default-project',
func: async (client) => {
const tx = new TxOperations(client, core.account.System)
await createSpace(tx)
await createDefaultTeamspaceType(tx)
}
}
])
// Currently space type has to be recreated every time as it's in the model
// created by the system user
await createDefaultTeamspaceType(tx)
}
}

View File

@ -32,7 +32,29 @@ async function createSpace (tx: TxOperations): Promise<void> {
_id: lead.space.DefaultFunnel
})
if (current === undefined) {
const type = await createProjectType(
await tx.createDoc(
lead.class.Funnel,
core.space.Space,
{
name: 'Funnel',
description: 'Default funnel',
private: false,
archived: false,
members: [],
type: lead.template.DefaultFunnel
},
lead.space.DefaultFunnel
)
}
}
async function createSpaceType (tx: TxOperations): Promise<void> {
const current = await tx.findOne(task.class.ProjectType, {
_id: lead.template.DefaultFunnel
})
if (current === undefined) {
await createProjectType(
tx,
{
name: 'Default funnel',
@ -101,19 +123,6 @@ async function createSpace (tx: TxOperations): Promise<void> {
],
lead.template.DefaultFunnel
)
await tx.createDoc(
lead.class.Funnel,
core.space.Space,
{
name: 'Funnel',
description: 'Default funnel',
private: false,
archived: false,
members: [],
type
},
lead.space.DefaultFunnel
)
}
}
@ -179,14 +188,17 @@ export const leadOperation: MigrateOperation = {
])
},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const ops = new TxOperations(client, core.account.System)
await tryUpgrade(client, leadId, [
{
state: 'u-default-funnel',
func: async (client) => {
const ops = new TxOperations(client, core.account.System)
func: async () => {
await createDefaults(ops)
}
}
])
// Currently space type has to be recreated every time as it's in the model
// created by the system user
await createSpaceType(ops)
}
}