mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-30 12:20:00 +00:00
Fix migration (#2593)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
9fef46b059
commit
33b06c24dc
@ -13,16 +13,16 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import { getCategories } from '@anticrm/skillset'
|
||||||
import { Organization } from '@hcengineering/contact'
|
import { Organization } from '@hcengineering/contact'
|
||||||
import core, { Doc, DOMAIN_TX, Ref, Space, TxCreateDoc, TxOperations } from '@hcengineering/core'
|
import core, { Doc, DOMAIN_TX, Ref, Space, TxCollectionCUD, TxOperations } from '@hcengineering/core'
|
||||||
import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||||
import { DOMAIN_CALENDAR } from '@hcengineering/model-calendar'
|
import { DOMAIN_CALENDAR } from '@hcengineering/model-calendar'
|
||||||
import contact, { DOMAIN_CONTACT } from '@hcengineering/model-contact'
|
import contact, { DOMAIN_CONTACT } from '@hcengineering/model-contact'
|
||||||
import { DOMAIN_SPACE } from '@hcengineering/model-core'
|
import { DOMAIN_SPACE } from '@hcengineering/model-core'
|
||||||
import tags, { TagCategory } from '@hcengineering/model-tags'
|
import tags, { TagCategory } from '@hcengineering/model-tags'
|
||||||
import { createKanbanTemplate, createSequence, DOMAIN_TASK } from '@hcengineering/model-task'
|
import { createKanbanTemplate, createSequence, DOMAIN_TASK } from '@hcengineering/model-task'
|
||||||
import { Applicant, Vacancy } from '@hcengineering/recruit'
|
import { Applicant, Candidate, Vacancy } from '@hcengineering/recruit'
|
||||||
import { getCategories } from '@anticrm/skillset'
|
|
||||||
import { KanbanTemplate } from '@hcengineering/task'
|
import { KanbanTemplate } from '@hcengineering/task'
|
||||||
import recruit from './plugin'
|
import recruit from './plugin'
|
||||||
|
|
||||||
@ -39,36 +39,42 @@ async function fixImportedTitle (client: MigrationClient): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setCreate (client: MigrationClient): Promise<void> {
|
async function setCreate (client: MigrationClient): Promise<void> {
|
||||||
const docs = await client.find<Applicant>(DOMAIN_TASK, {
|
while (true) {
|
||||||
_class: recruit.class.Applicant,
|
const docs = await client.find<Applicant>(
|
||||||
createOn: { $exists: false }
|
DOMAIN_TASK,
|
||||||
})
|
{
|
||||||
for (const doc of docs) {
|
_class: recruit.class.Applicant,
|
||||||
const tx = (
|
createOn: { $exists: false }
|
||||||
await client.find<TxCreateDoc<Applicant>>(DOMAIN_TX, {
|
},
|
||||||
objectId: doc._id,
|
{ limit: 500 }
|
||||||
_class: core.class.TxCreateDoc
|
)
|
||||||
})
|
if (docs.length === 0) break
|
||||||
)[0]
|
const txex = await client.find<TxCollectionCUD<Candidate, Applicant>>(DOMAIN_TX, {
|
||||||
if (tx !== undefined) {
|
'tx.objectId': { $in: docs.map((it) => it._id) },
|
||||||
await client.update(
|
'tx._class': core.class.TxCreateDoc
|
||||||
DOMAIN_CONTACT,
|
})
|
||||||
{
|
for (const doc of docs) {
|
||||||
_id: doc._id
|
const tx = txex.find((it) => it.tx.objectId === doc._id)
|
||||||
},
|
if (tx !== undefined) {
|
||||||
{
|
await client.update(
|
||||||
createOn: tx.modifiedOn
|
DOMAIN_TASK,
|
||||||
}
|
{
|
||||||
)
|
_id: doc._id
|
||||||
await client.update(
|
},
|
||||||
DOMAIN_TX,
|
{
|
||||||
{
|
createOn: tx.modifiedOn
|
||||||
_id: tx._id
|
}
|
||||||
},
|
)
|
||||||
{
|
await client.update(
|
||||||
'attributes.createOn': tx.modifiedOn
|
DOMAIN_TX,
|
||||||
}
|
{
|
||||||
)
|
_id: tx._id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'tx.attributes.createOn': tx.modifiedOn
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user