diff --git a/server/postgres/src/schemas.ts b/server/postgres/src/schemas.ts index d676413005..bb45ce0724 100644 --- a/server/postgres/src/schemas.ts +++ b/server/postgres/src/schemas.ts @@ -251,6 +251,15 @@ const docSyncInfo: Schema = { } } +const githubLogin: Schema = { + ...baseSchema, + login: { + type: 'text', + notNull: true, + index: true + } +} + export function addSchema (domain: string, schema: Schema): void { domainSchemas[translateDomain(domain)] = schema domainSchemaFields.set(domain, createSchemaFields(schema)) @@ -271,7 +280,8 @@ export const domainSchemas: Record = { notification: notificationSchema, [translateDomain('notification-dnc')]: dncSchema, [translateDomain('notification-user')]: userNotificationSchema, - github: docSyncInfo + [translateDomain('github_sync')]: docSyncInfo, + [translateDomain('github_user')]: githubLogin } export function getSchema (domain: string): Schema { diff --git a/services/github/model-github/src/index.ts b/services/github/model-github/src/index.ts index d1269ab8d1..2ea37c205b 100644 --- a/services/github/model-github/src/index.ts +++ b/services/github/model-github/src/index.ts @@ -95,9 +95,11 @@ export { githubId } from '@hcengineering/github' export { githubOperation, githubOperationPreTime } from './migration' export { default } from './plugin' export const DOMAIN_GITHUB = 'github' as Domain +export const DOMAIN_GITHUB_SYNC = 'github_sync' as Domain +export const DOMAIN_GITHUB_USER = 'github_user' as Domain export const DOMAIN_GITHUB_COMMENTS = 'github_comments' as Domain -@Model(github.class.DocSyncInfo, core.class.Doc, DOMAIN_GITHUB) +@Model(github.class.DocSyncInfo, core.class.Doc, DOMAIN_GITHUB_SYNC) export class TDocSyncInfo extends TDoc implements DocSyncInfo { // _id === objectId @Prop(TypeNumber(), getEmbeddedLabel('Github number')) @@ -152,7 +154,7 @@ export class TDocSyncInfo extends TDoc implements DocSyncInfo { deleted!: boolean } -@Model(github.class.GithubUserInfo, core.class.Doc, DOMAIN_GITHUB) +@Model(github.class.GithubUserInfo, core.class.Doc, DOMAIN_GITHUB_USER) export class TGithubUserInfo extends TDoc implements GithubUserInfo { @Prop(TypeString(), getEmbeddedLabel('ID')) @ReadOnly() diff --git a/services/github/model-github/src/migration.ts b/services/github/model-github/src/migration.ts index 1cef89abbb..fb2173b0fe 100644 --- a/services/github/model-github/src/migration.ts +++ b/services/github/model-github/src/migration.ts @@ -32,7 +32,7 @@ import github from './plugin' import { DOMAIN_TIME } from '@hcengineering/model-time' import { DOMAIN_TRACKER } from '@hcengineering/model-tracker' import time from '@hcengineering/time' -import { DOMAIN_GITHUB } from '.' +import { DOMAIN_GITHUB, DOMAIN_GITHUB_SYNC, DOMAIN_GITHUB_USER } from '.' export async function guessStatus (status: Status, statuses: Status[]): Promise { const active = (): Status => statuses.find((it) => it.category === task.statusCategory.Active) as Status @@ -328,6 +328,13 @@ export const githubOperationPreTime: MigrateOperation = { func: async (client) => { await client.deleteMany(DOMAIN_TX, { objectClass: github.class.DocSyncInfo }) } + }, + { + state: 'migrate-github-sync-domain', + func: async (client) => { + await client.move(DOMAIN_GITHUB, { _class: github.class.DocSyncInfo }, DOMAIN_GITHUB_SYNC) + await client.move(DOMAIN_GITHUB, { _class: github.class.GithubUserInfo }, DOMAIN_GITHUB_USER) + } } ]) },