There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: large transaction (#6695)
darkskygitea3f42791823
diff --git a/packages/backend/server/src/data/migrations/utils/prompts.ts b/packages/backend/server/src/data/migrations/utils/prompts.tsindex aaa6d5ba00..95d1f13497 100644--- a/packages/backend/server/src/data/migrations/utils/prompts.ts+++ b/packages/backend/server/src/data/migrations/utils/prompts.ts@@ -593,37 +593,35 @@ export const prompts: Prompt[] = [];export async function refreshPrompts(db: PrismaClient) {- await db.$transaction(async tx => {- for (const prompt of prompts) {- await tx.aiPrompt.upsert({- create: {- name: prompt.name,- action: prompt.action,- model: prompt.model,- messages: {- create: prompt.messages.map((message, idx) => ({- idx,- role: message.role,- content: message.content,- params: message.params,- })),- },+ for (const prompt of prompts) {+ await db.aiPrompt.upsert({+ create: {+ name: prompt.name,+ action: prompt.action,+ model: prompt.model,+ messages: {+ create: prompt.messages.map((message, idx) => ({+ idx,+ role: message.role,+ content: message.content,+ params: message.params,+ })),},- where: { name: prompt.name },- update: {- action: prompt.action,- model: prompt.model,- messages: {- deleteMany: {},- create: prompt.messages.map((message, idx) => ({- idx,- role: message.role,- content: message.content,- params: message.params,- })),- },+ },+ where: { name: prompt.name },+ update: {+ action: prompt.action,+ model: prompt.model,+ messages: {+ deleteMany: {},+ create: prompt.messages.map((message, idx) => ({+ idx,+ role: message.role,+ content: message.content,+ params: message.params,+ })),},- });- }- });+ },+ });+ }}diff --git a/packages/backend/server/src/data/migrations/utils/user-quotas.ts b/packages/backend/server/src/data/migrations/utils/user-quotas.tsindex 7a8c5f9677..3c7d9d0201 100644--- a/packages/backend/server/src/data/migrations/utils/user-quotas.ts+++ b/packages/backend/server/src/data/migrations/utils/user-quotas.ts@@ -13,56 +13,62 @@ export async function upgradeQuotaVersion(// add new quotaawait upsertFeature(db, quota);// migrate all users that using old quota to new quota- await db.$transaction(async tx => {- const latestQuotaVersion = await tx.features.findFirstOrThrow({- where: { feature: quota.feature },- orderBy: { version: 'desc' },- select: { id: true },- });+ await db.$transaction(+ async tx => {+ const latestQuotaVersion = await tx.features.findFirstOrThrow({+ where: { feature: quota.feature },+ orderBy: { version: 'desc' },+ select: { id: true },+ });- // find all users that have old free plan- const userIds = await tx.user.findMany({- where: {- features: {- some: {- feature: {- type: FeatureKind.Quota,- feature: quota.feature,- version: { lt: quota.version },+ // find all users that have old free plan+ const userIds = await tx.user.findMany({+ where: {+ features: {+ some: {+ feature: {+ type: FeatureKind.Quota,+ feature: quota.feature,+ version: { lt: quota.version },+ },+ activated: true,},- activated: true,},},- },- select: { id: true },- });+ select: { id: true },+ });- // deactivate all old quota for the user- await tx.userFeatures.updateMany({- where: {- id: undefined,- userId: {- in: userIds.map(({ id }) => id),+ // deactivate all old quota for the user+ await tx.userFeatures.updateMany({+ where: {+ id: undefined,+ userId: {+ in: userIds.map(({ id }) => id),+ },+ feature: {+ type: FeatureKind.Quota,+ },+ activated: true,},- feature: {- type: FeatureKind.Quota,+ data: {+ activated: false,},- activated: true,- },- data: {- activated: false,- },- });+ });- await tx.userFeatures.createMany({- data: userIds.map(({ id: userId }) => ({- userId,- featureId: latestQuotaVersion.id,- reason,- activated: true,- })),- });- });+ await tx.userFeatures.createMany({+ data: userIds.map(({ id: userId }) => ({+ userId,+ featureId: latestQuotaVersion.id,+ reason,+ activated: true,+ })),+ });+ },+ {+ maxWait: 10000,+ timeout: 20000,+ }+ );}export async function upsertLatestQuotaVersion(