Added unit test to detect orphaned migration folders#26355
Added unit test to detect orphaned migration folders#26355
Conversation
WalkthroughA new unit test file is added to validate migration version consistency. The test loads the current package.json version, derives a safe version using regex, and enumerates migration version folders that match a numeric dot-numeric pattern. It uses semver.coerce to compare each folder version against the safe version and asserts that no migration folders have versions greater than the current package.json version. An error message provides guidance on resolving any version mismatches by running a migration or updating package.json. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ref https://linear.app/ghost/issue/BER-3318/ knex-migrator silently skips migration folders that exceed the current Ghost version (folder > ghostVersion.safe). If a developer adds a migration folder without bumping package.json to an rc, those migrations will never run. This test catches that by scanning all version folders and failing when any exceed the safe version from package.json.
4ba881a to
6a5410f
Compare
ref https://linear.app/ghost/issue/BER-3318/
knex-migrator silently skips migration folders where the folder version exceeds
ghostVersion.safe(themajor.minorextracted frompackage.json). If a developer creates a migration folder for the next minor version without bumpingpackage.jsonto an rc, those migrations will never run.This adds a unit test that scans all version folders under
migrations/versions/and fails when any folder exceeds the current safe version. It uses the same regex as@tryghost/versionand the samesemver.gt/semver.coercecomparison that knex-migrator uses internally. The error message tells the developer exactly what to do: runslimer migration(which handles the bump automatically) or manually bumppackage.jsonto the next minor rc.This is part 3 of 3 for the rc version bump initiative (BER-3315). Part 2 (BER-3317, super-slimer auto-bump) ensures
slimer migrationbumpspackage.jsonto an rc automatically when creating a migration. This test is the safety net that catches cases where someone bypasses slimer and creates a migration folder manually.