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

Regression: SchemaError during version upgrade #1145

Closed
nifgraup opened this issue Oct 15, 2020 · 2 comments · Fixed by #1146
Closed

Regression: SchemaError during version upgrade #1145

nifgraup opened this issue Oct 15, 2020 · 2 comments · Fixed by #1146
Assignees
Labels

Comments

@nifgraup
Copy link

Steps
Run this minimal repro https://jsfiddle.net/av6gw2re/, same as the following:

const db = new Dexie("dbname");
db.version(1).stores({Y: "id"});
await db.open();
await db.close();

db.version(2).upgrade(trans => {
  console.log("Starting version 2 upgrade.")
  return trans.Y.count();
});
db.version(3).stores({
  Y: "id,X",
});
db.version(4).upgrade(trans => {
  console.log("Starting version 4 upgrade.")
  return trans.Y.where('X').equals('value').toArray();
});

try {
  await db.open();
} catch (e) {
  console.log(e);
} finally {
  await db.delete();
  console.log("All done.")
}

What happens

Starting version 2 upgrade.
Starting version 4 upgrade.
SchemaError: KeyPath X on object store Y is not indexed
All done.

Expected
No error as in Dexie 2:

Starting version 2 upgrade.
Starting version 4 upgrade.
All done.
@nifgraup
Copy link
Author

Regression point

commit 718f78980a033c7eac2ed3140c0dd52b9f170a4f
Author: David Fahlander <david.fahlander@gmail.com>
Date:   Fri Jun 1 15:14:25 2018 +0200

    Issue713 (#714)
    
    Making it possible to rename a table and also change primary key.
    
    Resolves #713
    Resolves #105

@dfahlander
Copy link
Collaborator

Thanks @nifgraup for the concise repro. The issue was a memoization in Transaction - if a table had been queried in an earlier upgrade, the old schema was reused later on.

dfahlander added a commit that referenced this issue Oct 16, 2020
dfahlander added a commit that referenced this issue Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants