How do you add a new index to an existing IndexedDB store?

Tests production schema migration discipline. Bump the integer version in open(), handle onupgradeneeded before onsuccess, use event.oldVersion for incremental changes, and guard against duplicate index creation.
Tests whether you understand IndexedDB's versioned schema lifecycle and production migration safety. A strong answer: increment the integer version in indexedDB.open, listen for onupgradeneeded which fires before onsuccess, branch on event.oldVersion to apply only missing changes, use objectStore.createIndex with overwrite or existence checks, and handle the blocked event for open tabs. Red flag: believing indexes can be added in standard readwrite transactions or omitting version bumping entirely.
Read the original → developer.mozilla.org
- #indexeddb
- #web-apis
- #schema-migration
- #typescript
- #browser-storage
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.