Let callers run deferred workspace migration actions in process

Merged
CH
1mo ago
+56-40

Prerequisite for removing IS_DEFERRED_WORKSPACE_MIGRATION_ACTIONS_ENABLED.

Deferred mode persists the slow parts of a migration (join column index builds, foreign key validation, workflow run and logic function cleanup) and leaves them to the worker. It also blocks the next schema-affecting migration until those actions finish. That suits a user editing their data model. It breaks callers that run many migrations back to back or run without a worker: with the flag on, seeding a workspace queues 152 actions and the very next createOneObject is rejected.

What changes

  • WorkspaceMigrationRunnerService.run and every WorkspaceMigrationValidateBuildAndRunService.validateBuildAndRun* method take an optional shouldDeferActions (default true), threaded the same way as dryRun. ObjectMetadataService.createOneObject, FieldMetadataService.createManyFields and updateOneField accept and forward it.
  • The standard app sync passes shouldDeferActions: false. It only runs at workspace creation and seeding, where more migrations follow right away.
  • The dev seeder passes shouldDeferActions: false on its object and field calls, since seeding runs without a worker.
  • The runner defers only when the flag is on and shouldDeferActions resolves to true. Otherwise it behaves as it does today with the flag off: indexes and foreign keys are built and validated inline, cleanup actions run right after commit.
  • The index and field handlers read shouldDeferActions from the runner context instead of the feature flag map. featureFlagsMap is dropped from that context since this flag was its only consumer.

No behaviour change while the flag stays on its current rollout. Upgrade and workspace commands keep the default: committed upgrade commands can't be edited, so they defer on flagged workspaces and rely on a running worker. New commands can pass shouldDeferActions: false.