Skip to content

Migrating existing DB to Dexie

David Fahlander edited this page Jun 13, 2016 · 52 revisions

Dexie can open any indexedDB database, no matter if you've created it via raw indexedDB or another indexedDB wrapper. It's very simple:

How to migrate

  1. Publish this HTML page somewhere in the same origin as your app resides (such as http://locahost:8080/dexie-migrate-temp/dump-databases.html).
  2. Use Chrome or Opera to navigate to your existing app (to ensure it will create the database your way). Then just navigate to the dump-database.html page and copy the generated code from the output.

That's all. After that, you may even use Dexie and your own raw indexedDB code / other wrapper in parallell if you like.

NOTE: Dexie will use the version number divided by 10. Nothing to be afraid of. It just is like that. Here's an explanation.

What will I see?

A log window will display the Dexie-code required to open it. It will show something like the following:

Dumping Databases
=================
var db = new Dexie('MyDB');
db.version(1).stores({
    friends: '++id,name,shoeSize'
});

var db = new Dexie('someDB');
db.version(3).stores({
    someTable: '++id,someIndex'
});

var db = new Dexie('todos-dexie');
db.version(1).stores({
    todo: '_id'
});

Finished dumping databases
==========================

Happy migration!

Clone this wiki locally