Skip to content
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

Resolving #1145 Regression: SchemaError during version upgrade #1146

Merged
merged 2 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/classes/version/schema-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export function updateTablesAndIndexes(
if (contentUpgrade && version._cfg.version > oldVersion) {
// Update db.core with new tables and indexes:
generateMiddlewareStacks(db, idbUpgradeTrans);
trans._memoizedTables = {}; // Invalidate memoization as transaction shape may change between versions.

anyContentUpgraderHasRun = true;

Expand Down
33 changes: 33 additions & 0 deletions test/tests-upgrading.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,36 @@ promisedTest("Issue #959 - Should migrate successfully with an explicit unique m
equal(result2.name, "Bar", "The expected friends was returned");
}
);


promisedTest(
"Issue 1145 - Regression: SchemaError during version upgrade",
async () => {
const DBNAME = "issue1145";
await Dexie.delete(DBNAME);
const db = new Dexie(DBNAME);
db.version(1).stores({ Y: "id" });
await db.open();
await db.close();
db.version(2).upgrade((trans) => {
ok(true, "Starting version 2 upgrade.");
return trans.Y.count();
});
db.version(3).stores({
Y: "id,X",
});
db.version(4).upgrade((trans) => {
ok(true, "Starting version 4 upgrade.");
return trans.Y.where("X").equals("value").toArray();
});

try {
await db.open();
ok(true, "Open successful");
} catch (e) {
ok(false, "Open Failed:: " + e);
} finally {
await db.delete();
}
}
);