Skip to content

Fixed knex-migrator scripts failing until workspace packages are built - #31747

Merged
9larsons merged 1 commit into
mainfrom
slars/peaceful-wiles-a342a6
Oct 10, 2026
Merged

9larsons merged 1 commit into
mainfrom
slars/peaceful-wiles-a342a6

Conversation

@9larsons

@9larsons 9larsons commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

pnpm reset:db, migrate:db, rollback:db and pnpm knex-migrator loaded workspace packages from build/, which only exists once pnpm dev has built them for Admin. Ghost itself runs from source. So in a new worktree these scripts failed with Cannot find module '…/@tryghost/limit-service/build/index.js', and elsewhere they ran the build from the last pnpm dev start instead of the current source.

  • knex-migrator now runs with NODE_OPTIONS='--conditions=source --import=tsx', the flags pnpm dev and pnpm reset:data give Ghost.
  • The flags go in NODE_OPTIONS because the knex-migrator bin runs each subcommand as a separate process. env limits them to knex-migrator, so an automatic install started by pnpm exec doesn't run lifecycle scripts with --import=tsx.

Verified in a new worktree after pnpm bootstrap only. knex-migrator init failed on main and now succeeds. reset:db, migrate:db and a rollback --force/migrate --force round trip succeed against dev_<worktree>, and an install from stale dependencies no longer fails.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: TryGhost/Ghost/.coderabbit.yaml
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 37fd3bb8-be9a-4f08-8611-31f24d335760

📥 Commits

Reviewing files that changed from the base of the PR and between 417e2f9 and a0123ad.


📒 Files selected for processing (1)
  • package.json

 ___________________________
< Goodbye, overlooked bugs. >
 ---------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit a0123ad

Command Status Duration Result
nx run ghost:test:ci:unit ✅ Succeeded 1m 36s View ↗
nx run-many -t test:unit -p @internal/scripts,@... ✅ Succeeded 10m 10s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 54s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 3s View ↗
nx run @tryghost/admin:test:acceptance --shard=3/3 ✅ Succeeded 6m 5s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 5m 37s View ↗
nx run @tryghost/admin:test:acceptance --shard=2/3 ✅ Succeeded 6m 6s View ↗
nx run @tryghost/admin:test:acceptance --shard=1/3 ✅ Succeeded 5m 39s View ↗
Additional runs (17) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-10 17:28:08 UTC

@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.15%. Comparing base (417e2f9) to head (a0123ad).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #31747      +/-   ##
==========================================
- Coverage   85.24%   85.15%   -0.09%     
==========================================
  Files        1365     1365              
  Lines       51276    51276              
  Branches     8809     8809              
==========================================
- Hits        43710    43665      -45     
- Misses       6471     6511      +40     
- Partials     1095     1100       +5     
Flag Coverage Δ
e2e-tests 72.35% <ø> (-0.01%) ⬇️
unit-tests 67.43% <ø> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

no ref

`pnpm reset:db`, `migrate:db`, `rollback:db` and `knex-migrator` loaded
workspace packages from `build/`, which only exists once `pnpm dev` has
built them for Admin. Ghost itself runs from source
(`--conditions=source --import=tsx`), so in a new worktree these scripts
failed with MODULE_NOT_FOUND for `@tryghost/limit-service/build/index.js`,
and elsewhere they ran the build from the last `pnpm dev` start rather
than the current source.

The flags go in NODE_OPTIONS because the `knex-migrator` bin runs each
subcommand as a separate process, which doesn't inherit Node's
command-line flags. `env` sets them on knex-migrator alone: set on
`pnpm exec`, they'd also reach the lifecycle scripts of an automatic
install, where `--import=tsx` doesn't resolve.
@9larsons
9larsons force-pushed the slars/peaceful-wiles-a342a6 branch from 933600c to a0123ad Compare October 10, 2026 17:14
@9larsons
9larsons marked this pull request as ready for review October 10, 2026 18:31
@9larsons
9larsons merged commit a2858eb into main Oct 10, 2026
67 of 68 checks passed
@9larsons
9larsons deleted the slars/peaceful-wiles-a342a6 branch October 10, 2026 18:31
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