-
Notifications
You must be signed in to change notification settings - Fork 1
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
[BUG]: Cannot find target migration ${target} in applied migrations #21
Comments
Can I ask a few questions: Are you getting the error:
This test is meant to find your target version 0.0.1 in the list of past versions. Do you have a 0.0.1 in the past versions? |
@mobsense I am getting that error. A quick clarification as well, the above test I took cli.js and removed all the // onetable-cli/blob/main/src/cli.js#L288
let pastMigrations = await this.migrate.getPastMigrations()
let pastVersions = pastMigrations.filter(m => Semver.valid(m.version)) This is used to populate pastVersions. I made sure the test resolves 0.0.1, 0.0.2, and 0.0.3, it still fails due to the line: // onetable-cli/blob/main/src/cli.js#L338
if (target != '0.0.0' && !pastVersions.find(p => p == target)) { Because
Date Version Description
18:43:00 Nov 6, 2024 0.0.1 Test migration 0.0.1 |
Ah, thank you. It should be:
Let me know if that works for you. |
Looks like what will fix it is: cmd = "down";
// pastVersions is `Record<string, any>[]` so we can get `p.version == target`
if (target != "0.0.0" && !pastVersions.find((p) => p.version == target).length === 0) {
error(`Cannot find target migration ${target} in applied migrations`);
}
// We also need to use `v.version` here
versions = pastVersions
.reverse()
.filter((v) => Semver.compare(v.version, target) > 0); We know let pastVersions = pastMigrations.filter(m => Semver.valid(m.version)) Could also fix this by doing: let pastVersions = pastMigrations.map(m => m.version).filter(m => Semver.valid(m));
// still need to fix the if logic
if (target != "0.0.0" && !pastVersions.find((p) => p == target).length === 0) {
error(`Cannot find target migration ${target} in applied migrations`);
} |
Thanks, will test that. |
Describe the bug
I was trying to use the cli to execute a migration from version 0.0.3 to 0.0.1. I received the error above. After reviewing the code at https://github.com/sensedeep/onetable-cli/blob/main/src/cli.js#L338 I determined this was a bug in the logic within the
if
logic.To Reproduce
Steps to reproduce the behavior:
I create a vitest and mocked out everything I could to isolate the issue. Jest is not friendly with
"type": "module"
projects.Expected behavior
I was expecting that the cli would execute 0.0.3
down
and then 0.0.2down
migrations.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: