-
Notifications
You must be signed in to change notification settings - Fork 376
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
Duplicate Index Names #499
Comments
It appears that models can't be synced in parallel. You need to do it in series: var sequence = require('when/sequence');
function bootstrapModels(db) {
console.log('Bootstrapping models...');
var createTable = function (model) {
var deferred = when.defer();
model.sync(function (err) {
if (err) deferred.reject(err);
else deferred.resolve(true);
});
return deferred.promise;
}
var jobs = Object.keys(db.models).map(function (k) {
return createTable.bind(null, db.models[k]);
});
return sequence(jobs);
} If you change your connect call to: |
Thanks for the help! I didn't know about ?debug=true on the connector, very useful. Changing from asynchronous to synchronous didn't solve my problem though. It still errors on attempting to create a duplicate index. I have created a simplified test case to exhibit this behavior: There exists As, Bs and Cs. This setup results in:
The code:
|
When I tested I simplified the code such that I only had 1 association and I hit the |
Please install the latest version (2.1.12). The issue should be resolved. I forgot to commit the test case along with the release. Added it in a subsequent commit. |
That worked great! Thank you for the quick fix. |
I have what appears to be a pretty simple relation mapping, but it keeps failing during sync. This is due to:
It seems that a model can only ever be part of one many to many relationship! Is there any way I can give custom names to the indices for each relationship? Or some other way I can avoid this error? Code below:
database.js
bootstrap.js
The text was updated successfully, but these errors were encountered: