Can't do async data migrations in the sync upgrade function
See original GitHub issueIt seems that all methods of retrieving items from a store return a promise, which can’t be awaited in the upgrade function.
Let’s say my blogPost type has changed. The ID used to be a number, but is now a string, Then it would be nice to be able to do something like this:
upgrade(db, oldVersion, newVersion, transaction) {
const blogPosts = await db.getAll('blogPosts') // Oh, no! We can't await anything here
db.deleteObjectStore('blogPosts')
// Re-create the store with the new schema
// Remap and save all the items
}
It would be nice if the upgrade function was async so that this type of thing can be done.
Is there any workaround for this?
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
[Question]Can i use async db driver to serve db changes? #805
Hi guys! I'm newbie with alembic and wanted clarify one thing. As i understood based on docs, alembic uses sync database driver(for example, ......
Read more >Sequelize.js: how to use migrations and sync - Stack Overflow
Generating the "first migration". In your case, the most reliable way is to do it almost manually. I would suggest to use sequelize-cli...
Read more >Update on Async Rendering – React Blog
The recommended upgrade path for most use cases is to move data-fetching into componentDidMount :
Read more >How to automate database migrations in MongoDB
Introduction · Write a script that will take care of upgrading the schema as well as downgrading it to previous versions · Update...
Read more >From Sync to Async - WebdriverIO
Due to changes in V8 the WebdriverIO team announced to deprecate synchronous command execution by April 2023. The team has been working hard...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s amazing, thanks for your help!
No problem! The lifetime of IDB transitions is pretty weird, unfortunately I can’t really change that 😄