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

Perform version upgrades after importing a database #79

Open
QuentinRoy opened this issue Jul 16, 2021 · 0 comments
Open

Perform version upgrades after importing a database #79

QuentinRoy opened this issue Jul 16, 2021 · 0 comments

Comments

@QuentinRoy
Copy link

QuentinRoy commented Jul 16, 2021

Feature Request
Available Version.upgrade could be run when using importInto.

Use Case
I am using Dexie export to let my users locally save and share their work. After a model upgrade, a run into the issue of version incompatibility.
Dexie has a very nice version upgrade feature that I have been happily leveraging when creating my database from indexedDB, unfortunately it won't work when using importInto.

Current Workaround

async function import(file: File) {
  // Completely delete the current data base. Import should overwrite
  // everything anyway.
  await db.delete();
  // Export file may be outdated. For this reason, we cannot use
  // importInto. Instead, we import the new database in a new (default)
  // Dexie instance to save the potentially outdated data in instance db.
  let newDb = await importDB(file);
  await newDb.close();
  // Recreate the database using our custom database class. This
  // will trigger the version upgrade if needed.
  db = new Database();
  await db.open();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant