Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

chore(migrations): run the piece-translation backfill before the flow_run index reshape (#17119)

Amr Elmohamadyee4cbaca2803
diff --git a/packages/server/api/src/app/database/postgres-connection.ts b/packages/server/api/src/app/database/postgres-connection.ts
index 337782ce2f9..a87c13142fb 100644
--- a/packages/server/api/src/app/database/postgres-connection.ts
+++ b/packages/server/api/src/app/database/postgres-connection.ts
@@ -482,8 +482,8 @@ const getSslConfig = (): boolean | TlsOptions => {
export const getBackgroundMigrations = (): (new () => BackgroundMigration)[] => {
return [
AddAgentConversationProviderConfigIdIndex1869000000000,
- ReshapeFlowRunListIndexesForBarrierChildren1871000000000,
BackfillPieceTranslation1874000000000,
+ ReshapeFlowRunListIndexesForBarrierChildren1871000000000,
]
}
diff --git a/packages/server/api/test/integration/ce/database/background-migration-runner.test.ts b/packages/server/api/test/integration/ce/database/background-migration-runner.test.ts
index fb304011a0f..94e139b8908 100644
--- a/packages/server/api/test/integration/ce/database/background-migration-runner.test.ts
+++ b/packages/server/api/test/integration/ce/database/background-migration-runner.test.ts
@@ -8,6 +8,9 @@ import {
} from '../../../../src/app/database/background-migration-runner'
import { databaseConnection } from '../../../../src/app/database/database-connection'
import { BackgroundMigrationNotCompleteError, migrationHelpers } from '../../../../src/app/database/migration-helpers'
+import { BackfillPieceTranslation1874000000000 } from '../../../../src/app/database/migration/postgres/background/1874000000000-BackfillPieceTranslation'
+import { ReshapeFlowRunListIndexesForBarrierChildren1871000000000 } from '../../../../src/app/database/migration/postgres/background/1871000000000-ReshapeFlowRunListIndexesForBarrierChildren'
+import { getBackgroundMigrations } from '../../../../src/app/database/postgres-connection'
import { setupTestEnvironment, teardownTestEnvironment } from '../../../helpers/test-setup'
let app: FastifyInstance | null = null
@@ -156,6 +159,16 @@ describe('backgroundMigrationRunner', () => {
})
})
+describe('getBackgroundMigrations', () => {
+ it('runs the quick piece-translation backfill before the hours-long flow_run index reshape', () => {
+ const order = getBackgroundMigrations()
+
+ expect(order.indexOf(BackfillPieceTranslation1874000000000)).toBeGreaterThanOrEqual(0)
+ expect(order.indexOf(BackfillPieceTranslation1874000000000)).toBeLessThan(order.indexOf(ReshapeFlowRunListIndexesForBarrierChildren1871000000000))
+ expect(order.at(-1)).toBe(ReshapeFlowRunListIndexesForBarrierChildren1871000000000)
+ })
+})
+
describe('runMigrationsWithCatchup', () => {
afterEach(() => vi.restoreAllMocks())