Skip to content

Commit

Permalink
Extract github domains (#7420)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <[email protected]>
  • Loading branch information
BykhovDenis authored Dec 10, 2024
1 parent d3e74ae commit 087cf2a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
12 changes: 11 additions & 1 deletion server/postgres/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -271,7 +280,8 @@ export const domainSchemas: Record<string, Schema> = {
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 {
Expand Down
6 changes: 4 additions & 2 deletions services/github/model-github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion services/github/model-github/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Status> {
const active = (): Status => statuses.find((it) => it.category === task.statusCategory.Active) as Status
Expand Down Expand Up @@ -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)
}
}
])
},
Expand Down

0 comments on commit 087cf2a

Please sign in to comment.