diff --git a/models/all/src/migration.ts b/models/all/src/migration.ts index 21b1899b63..da92c115cd 100644 --- a/models/all/src/migration.ts +++ b/models/all/src/migration.ts @@ -22,6 +22,7 @@ import { contactOperation } from '@hcengineering/model-contact' import { coreOperation } from '@hcengineering/model-core' import { gmailOperation } from '@hcengineering/model-gmail' import { leadOperation } from '@hcengineering/model-lead' +import { preferenceOperation } from '@hcengineering/model-preference' import { notificationOperation } from '@hcengineering/model-notification' import { settingOperation } from '@hcengineering/model-setting' import { recruitOperation } from '@hcengineering/model-recruit' @@ -37,10 +38,12 @@ import { demoOperation } from '@hcengineering/model-demo' import { hrOperation } from '@hcengineering/model-hr' import { documentOperation } from '@hcengineering/model-document' import { bitrixOperation } from '@hcengineering/model-bitrix' +import { calendarOperation } from '@hcengineering/model-calendar' export const migrateOperations: [string, MigrateOperation][] = [ ['core', coreOperation], ['chunter', chunterOperation], + ['calendar', calendarOperation], ['demo', demoOperation], ['gmail', gmailOperation], ['templates', templatesOperation], @@ -49,6 +52,7 @@ export const migrateOperations: [string, MigrateOperation][] = [ ['attachment', attachmentOperation], ['automation', automationOperation], ['lead', leadOperation], + ['preference', preferenceOperation], ['recruit', recruitOperation], ['view', viewOperation], ['contact', contactOperation], diff --git a/models/bitrix/src/migration.ts b/models/bitrix/src/migration.ts index 3e20bd1b32..b2d72945ce 100644 --- a/models/bitrix/src/migration.ts +++ b/models/bitrix/src/migration.ts @@ -13,9 +13,34 @@ // limitations under the License. // +import core, { TxOperations } from '@hcengineering/core' import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model' +import bitrix from './plugin' + +async function createSpace (tx: TxOperations): Promise { + const current = await tx.findOne(core.class.Space, { + _id: bitrix.space.Mappings + }) + if (current === undefined) { + await tx.createDoc( + core.class.Space, + core.space.Space, + { + name: 'Bitrix mappings', + description: 'Bitrix mappings', + private: false, + archived: false, + members: [] + }, + bitrix.space.Mappings + ) + } +} export const bitrixOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise {}, - async upgrade (client: MigrationUpgradeClient): Promise {} + async upgrade (client: MigrationUpgradeClient): Promise { + const tx = new TxOperations(client, core.account.System) + await createSpace(tx) + } } diff --git a/models/calendar/src/index.ts b/models/calendar/src/index.ts index f7f985935a..c142fc72a8 100644 --- a/models/calendar/src/index.ts +++ b/models/calendar/src/index.ts @@ -200,4 +200,5 @@ export function createModel (builder: Builder): void { }) } +export { calendarOperation } from './migration' export default calendar diff --git a/models/calendar/src/migration.ts b/models/calendar/src/migration.ts new file mode 100644 index 0000000000..412892955a --- /dev/null +++ b/models/calendar/src/migration.ts @@ -0,0 +1,46 @@ +// +// Copyright © 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import core, { TxOperations } from '@hcengineering/core' +import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model' +import calendar from './plugin' + +async function createSpace (tx: TxOperations): Promise { + const current = await tx.findOne(core.class.Space, { + _id: calendar.space.PersonalEvents + }) + if (current === undefined) { + await tx.createDoc( + core.class.Space, + core.space.Space, + { + name: 'Personal Events', + description: 'Personal Events', + private: false, + archived: false, + members: [] + }, + calendar.space.PersonalEvents + ) + } +} + +export const calendarOperation: MigrateOperation = { + async migrate (client: MigrationClient): Promise {}, + async upgrade (client: MigrationUpgradeClient): Promise { + const tx = new TxOperations(client, core.account.System) + await createSpace(tx) + } +} diff --git a/models/chunter/src/migration.ts b/models/chunter/src/migration.ts index 51fac97297..83ef2ada6d 100644 --- a/models/chunter/src/migration.ts +++ b/models/chunter/src/migration.ts @@ -62,6 +62,26 @@ export async function createRandom (tx: TxOperations): Promise { } } +async function createBacklink (tx: TxOperations): Promise { + const current = await tx.findOne(core.class.Space, { + _id: chunter.space.Backlinks + }) + if (current === undefined) { + await tx.createDoc( + core.class.Space, + core.space.Space, + { + name: 'Backlinks', + description: 'Backlinks', + private: false, + archived: false, + members: [] + }, + chunter.space.Backlinks + ) + } +} + export async function setCreate (client: TxOperations): Promise { const messages = (await client.findAll(chunter.class.Message, {})) .filter((m) => m.createBy === undefined) @@ -201,6 +221,7 @@ export const chunterOperation: MigrateOperation = { const tx = new TxOperations(client, core.account.System) await createGeneral(tx) await createRandom(tx) + await createBacklink(tx) await setCreate(tx) } } diff --git a/models/preference/src/index.ts b/models/preference/src/index.ts index cabe5cfc7b..9441e06d83 100644 --- a/models/preference/src/index.ts +++ b/models/preference/src/index.ts @@ -35,3 +35,4 @@ export function createModel (builder: Builder): void { } export { preference as default } +export { preferenceOperation } from './migration' diff --git a/models/preference/src/migration.ts b/models/preference/src/migration.ts new file mode 100644 index 0000000000..8a701a96c0 --- /dev/null +++ b/models/preference/src/migration.ts @@ -0,0 +1,51 @@ +// +// Copyright © 2023 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { TxOperations } from '@hcengineering/core' +import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model' +import core from '@hcengineering/model-core' +import preference from '@hcengineering/preference' + +async function createSpace (tx: TxOperations): Promise { + const current = await tx.findOne(core.class.Space, { + _id: preference.space.Preference + }) + if (current === undefined) { + await tx.createDoc( + core.class.Space, + core.space.Space, + { + name: 'Preference', + description: 'Preference space', + private: false, + archived: false, + members: [] + }, + preference.space.Preference + ) + } +} + +async function createDefaults (tx: TxOperations): Promise { + await createSpace(tx) +} + +export const preferenceOperation: MigrateOperation = { + async migrate (client: MigrationClient): Promise {}, + async upgrade (client: MigrationUpgradeClient): Promise { + const ops = new TxOperations(client, core.account.System) + await createDefaults(ops) + } +} diff --git a/models/setting/src/migration.ts b/models/setting/src/migration.ts index 27560db57c..4241b95438 100644 --- a/models/setting/src/migration.ts +++ b/models/setting/src/migration.ts @@ -13,9 +13,34 @@ // limitations under the License. // +import core, { TxOperations } from '@hcengineering/core' import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model' +import setting from './plugin' + +async function createSpace (tx: TxOperations): Promise { + const current = await tx.findOne(core.class.Space, { + _id: setting.space.Setting + }) + if (current === undefined) { + await tx.createDoc( + core.class.Space, + core.space.Space, + { + name: 'Setting', + description: 'Setting space', + private: false, + archived: false, + members: [] + }, + setting.space.Setting + ) + } +} export const settingOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise {}, - async upgrade (client: MigrationUpgradeClient): Promise {} + async upgrade (client: MigrationUpgradeClient): Promise { + const tx = new TxOperations(client, core.account.System) + await createSpace(tx) + } }