-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: d1 migrations create to use the highest migration number plus one #5184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: d1 migrations create to use the highest migration number plus one #5184
Conversation
🦋 Changeset detectedLatest commit: c0d21ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| const migrationNumbers = getMigrationNames(migrationsPath).map((migration) => | ||
| parseInt(migration.split("_")[0]) | ||
| ); | ||
| const highestMigrationNumber = Math.max(...migrationNumbers, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This explicitly makes the first number 0 + 1, which is a regression to how it works currently where the first number is 0.
If regression is unwanted, putting it to -1 will make it -1 + 1 = 0.
| const highestMigrationNumber = Math.max(...migrationNumbers, 0); | |
| const highestMigrationNumber = Math.max(...migrationNumbers, -1); |
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-wrangler-5184You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5184/npm-package-wrangler-5184Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-wrangler-5184 dev path/to/script.jsAdditional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-create-cloudflare-5184 --no-auto-updatenpm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-cloudflare-kv-asset-handler-5184npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-miniflare-5184npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-cloudflare-pages-shared-5184npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8177849191/npm-package-cloudflare-vitest-pool-workers-5184Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5184 +/- ##
==========================================
+ Coverage 70.35% 70.38% +0.03%
==========================================
Files 298 298
Lines 15567 15565 -2
Branches 4007 4006 -1
==========================================
+ Hits 10952 10956 +4
+ Misses 4615 4609 -6
|
|
Just holding off merging this until #4930 is in |
What this PR solves / how to test
Previously, if you wanted to remove a migration (e.g. number 5 out of 10), you had to:
SELECT ...just to have a query in it; orPreviously:
After:
Author has addressed the following
This PR changes the logic of
getNextMigrationNumberto actually get the highest migration number plus one, rather than the first missing migration number plus one, which can be an existing migration number.