0Pricing
JavaScript Academy · Lesson

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

  1. Opening a Database
  2. Transactions and CRUD
  3. Indexes and Queries
  4. Versioning and Upgrades
← Back to JavaScript Academy