When indexeddb upgrades the version number, how do I add an index to the old table?

for example, createObjectStore reported an error when upgrading the version number, because the table has already been created, and the index is also created when the table is created
how can I add a new index to the old table when the database version is upgraded?


you need to create a new object repository or delete an object repository from the previous version that is no longer needed. If you need to modify an existing object repository (for example, to modify keyPath), you must first delete the original object repository and then create it with the new settings. (note that this will lose the data in the object repository, and if you need to save this information, you need to read it out and save it elsewhere before the database version is updated.)

Menu