Skip to content

feat(workflow-executor): add migrate command and --skip-migrations#1700

Open
Scra3 wants to merge 1 commit into
mainfrom
feat/executor-migrate-command
Open

feat(workflow-executor): add migrate command and --skip-migrations#1700
Scra3 wants to merge 1 commit into
mainfrom
feat/executor-migrate-command

Conversation

@Scra3

@Scra3 Scra3 commented Jun 23, 2026

Copy link
Copy Markdown
Member

What

Three boot modes for the executor — progressive disclosure, no boot-time lock:

npx @forestadmin/workflow-executor                    # default: auto-migrate at boot, then run (unchanged)
npx @forestadmin/workflow-executor migrate            # apply migrations, then exit (one-shot for CI/release)
npx @forestadmin/workflow-executor --skip-migrations  # boot without migrating (DDL-readonly instance)

Why

Migrations run inside every booting instance (Runner.start()runStore.init()). For a single instance (demos/staging) that's fine; for N concurrent boots they race on SequelizeMeta. Rather than add boot-time locking plumbing, let serious deployments decouple: run migrate once in CI, then start N instances with --skip-migrations → zero race, no lock.

The default is deliberately left with no concurrency handling — simple by default, controllable when needed.

How

  • Runner: skipMigrations? config — start() skips runStore.init() when set. New migrate() applies migrations then closes the connection (no agent probe, no server, no polling) so the one-shot process exits.
  • build-workflow-executor: skipMigrations? on ExecutorOptions threaded to the runner; migrate() exposed on WorkflowExecutor.
  • cli-core: migrate positional command + --skip-migrations flag; runCli routes migrate to executor.migrate() (does not start the server). Help + README updated.

One migration code path (runStore.init()), two entry points. No new dependency, no advisory lock, no transaction gymnastics.

Tests

  • parseArgs: migrate and --skip-migrations; unknown args still throw.
  • runCli: migrate calls executor.migrate() and not start(); --skip-migrations threads skipMigrations: true into the build options and still starts.
  • Runner: start() with skipMigrations does not call runStore.init; migrate() calls init then close and does not probe the agent.
  • All touched suites green.

🤖 Generated with Claude Code

Note

Add migrate subcommand and --skip-migrations flag to workflow-executor CLI

  • Adds a migrate subcommand to the CLI that runs database migrations and exits without starting the HTTP server or polling, useful for running migrations separately in concurrent deployments.
  • Adds a --skip-migrations flag that boots the executor without running migrations, intended for use when migrations are applied out-of-band via the migrate subcommand.
  • Adds a migrate() method to the Runner and WorkflowExecutor interfaces that initializes the run store and closes it without probing the agent or starting normal activities.
  • Risk: when --skip-migrations is set, queries will fail if the schema has not been migrated separately.

Macroscope summarized 1d77bb3.

@qltysh

qltysh Bot commented Jun 23, 2026

Copy link
Copy Markdown

1 new issue

Tool Category Rule Count
qlty Structure Function with many returns (count = 4): runCli 1

Decouple migrations from boot without adding boot-time locking. Default
behaviour is unchanged (auto-migrate on start, no concurrency handling).

- `migrate` runs migrations then exits (one-shot for CI/release): Runner.migrate
  applies migrations and closes the connection, no agent probe / server / polling.
- `--skip-migrations` boots without migrating (Runner.start skips runStore.init),
  for instances behind a pipeline that already ran `migrate`.

Multi-instance deployments run `migrate` once then start N instances with
--skip-migrations: zero boot-time race, no lock needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the feat/executor-migrate-command branch from c8469f6 to 1d77bb3 Compare June 23, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant