-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with existing db #30
Comments
Migration is quite untested, but it reminds me that I should add some unit tests for it to find if we have issues with it. I would like to improve the migration capabilities since it is an important use case. A good tool to find out how your existing DB can be migrated to Dexie can be found here: Put that page on your site somewhere and navigate to it. You will get the code needed to define your DB with Dexie. One specific thing with Dexie is that your index names must be identical to your keypaths. If you have compound indexes, their names must have the following name format: "[" + keyPath1 + "+" + keyPath2 + ... + "]". Do you have an URL where it is possible to access your application and try debug why the migration is not working? I could give it a try and at the same time learn how to improve the migration capabilities of Dexie. |
Sorry, I don't have the application publically availible right now. I might be able to put together a test environment but you would need to login. Can I send some info by mail to you? Do you have gmail address or similar where I can reach you? I have firstname (johan) dot lastname (bergens) at gmail. |
Thanks for the access to your site. I was able to test a dexie migration on your data by simulating your URL locally using a local node.js server and some manipulation with my hosts file to pretend being your server. Then I put This file on the node.js server and could dump the data. I could see that your index names are not same as their corresponding keyPaths, which is the source of the problem. Since I would like to make it easy to migrate to Dexie, I will try improving the library so that it adjusts to the existing index names rather than requiring them to be identical to the keypaths. I could get the exception though by catching the final promise: var db = new Dexie('reqsSbaData');
db.version(0.2).stores({
_lookupFields: 'Id',
_offlineInfo: 'Id',
protocolEntities: 'ID',
protocolParts: 'ID,Protokoll',
protocolPoints: 'ID,Protokolldel',
remarkTexts: 'ID,keyValue,remarkType,valueField',
remarks: 'ID,Föräldraentitet,Protokoll,Protokollpunkt',
serverTypeInfo: 'ID'
});
db.open().then(function() {
console.log("Successfully opened the db"); // This was printed out
return db.protocolPoints.orderBy("Protokolldel").each(function(item) {
console.log("protocolPoint: " + JSON.stringify(item, null, 4));
});
}).catch(function(err) {
console.error(err); // I ended up here with a DOMException for not finding the index.
}); I'll keep this issue be open and write some unit tests that reproduces the problem to begin with. I also detected an issue with db.on('error') that it did not log the error there, only if i catched the error explicitely. Will be filed as a separate issue. |
Thanks for the help! I will fix my indices tomorrow and use catch after open too view any errors.
|
Added a unit test for issue #30 that currently fails when start using migrated indexes.
Now the unit test for issue #30 pass. (an error on one assertion in the unit test was also corrected) This fix makes Dexie adjust to existing databases created by other libraries. Before there was a requirement that the names of the indexes had to match their corresponding keypaths. Now Dexie will adapt the existing index names while still keeping its simple schema API and only specifying keyPaths like before. The real name of the index is only adapted internally when doing the querys.
Issue fixed in src/Dexie.js. The fix will be part of the next version of Dexie. Until then, use src/Dexie.js. With the fix, it is now easy to migrate to Dexie since it will no longer require any special format of the index names - it will adapt to the names that your existing db use. |
I currently have a problem with Dexie when I try it out with our existing indexedDb (already created in my browser by earlier code). The db seems to be blocked and the code never gets to the resolve parts in the promises parts.
Is this usecase (existing db with some indices) not supported?
It works with a small toy db built from scratch with Dexie with code in the same project.
The text was updated successfully, but these errors were encountered: