Versioning and Upgrades
Migrate schemas with version changes.
Why Versioning?
Apps evolve: you add stores, add indexes, or change how data is shaped. IndexedDB uses a version number to manage these schema changes safely across every user's browser.
The Version Number
The second argument to open is the version, a positive integer. Raising it tells the browser the schema has changed and triggers an upgrade.
// Bumping from 1 to 2 triggers onupgradeneeded:
const request = indexedDB.open('app-db', 2);All lessons in this course
- Opening a Database
- Transactions and CRUD
- Indexes and Queries
- Versioning and Upgrades