⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(migration): retain malformed configurations on existing projects
Tin061aec46b0e3
diff --git a/apps/api/src/migrations/column-migration.ts b/apps/api/src/migrations/column-migration.tsindex 23b596e21..878781ce1 100644--- a/apps/api/src/migrations/column-migration.ts+++ b/apps/api/src/migrations/column-migration.ts@@ -65,12 +65,10 @@ async function migrateProject(projectId: string, pending: Set<string>) {const legacy = projectColumns.length === 0;// Existing columns are the durable evidence of the old migration. Without// this inference the first upgrade would restore rules users already deleted.- if (!legacy && pending.size === 0) return true;const integrations = await tx.query.integrationTable.findMany({where: and(eq(integrationTable.projectId, projectId),inArray(integrationTable.type, ["github", "gitea"]),- legacy ? undefined : inArray(integrationTable.id, [...pending]),),});if (!legacy && integrations.length === 0) return true;@@ -110,6 +108,7 @@ async function migrateProject(projectId: string, pending: Set<string>) {complete = false;continue;}+ if (!legacy && !pending.has(integration.id)) continue;const forgeType = integration.type as "github" | "gitea";for (const [key, eventType] of Object.entries(EVENT_MAPPING)) {const slug = config.statusTransitions?.[key];diff --git a/tests/api-integration/column-migration-once.test.ts b/tests/api-integration/column-migration-once.test.tsindex 754ef017f..baa7b05f1 100644--- a/tests/api-integration/column-migration-once.test.ts+++ b/tests/api-integration/column-migration-once.test.ts@@ -59,14 +59,32 @@ it("preserves missing user-managed default rules on an already migrated project"it("skips malformed legacy configuration without blocking startup", async () => {const { workspace } = await createWorkspaceMember();const { project } = await createProjectFixture({ workspaceId: workspace.id });- await db.insert(schema.integrationTable).values({- projectId: project.id,- type: "gitea",- isActive: true,- config: "{",- });+ const [integration] = await db+ .insert(schema.integrationTable)+ .values({+ projectId: project.id,+ type: "gitea",+ isActive: true,+ config: "{",+ })+ .returning();await expect(migrateColumns()).resolves.toBeUndefined();- expect(await db.select().from(schema.dataMigrationTable)).toHaveLength(1);+ expect(await db.select().from(schema.dataMigrationTable)).toEqual([+ expect.objectContaining({+ id: `column-workflow-pending:${integration.id}`,+ }),+ ]);+ await db+ .update(schema.integrationTable)+ .set({+ config: JSON.stringify({ statusTransitions: { onPROpen: "to-do" } }),+ })+ .where(eq(schema.integrationTable.id, integration.id));+ await migrateColumns();+ expect(await db.select().from(schema.workflowRuleTable)).toHaveLength(3);+ expect(await db.select().from(schema.dataMigrationTable)).toEqual([+ expect.objectContaining({ id: "column-workflow-v1" }),+ ]);});it("migrates disabled legacy integrations and does not restore later deletions", async () => {