Hi,
I’m trying to upgrade ACE Framework to 3.4.0 which removes the jugglingDB and introduces sequelize adapter.
I’m facing “SequelizeUniqueConstraintError” during the schema sync
This is how i’m starting the server
addon.schema.sync().then(function(){
http.createServer(app).listen(port)(function(){
//server started
});
}
Error:
Executing (default): CREATE INDEX "addon_settings_client_key_key" ON "AddonSettings" ("clientKey", "key") { logging: [Function],
plain: false,
raw: true,
benchmark: undefined,
transaction: undefined,
fields: [ 'clientKey', 'key' ],
parser: null,
name: 'addon_settings_client_key_key',
prefix: 'AddonSettings',
supportsSearchPath: false,
type: 'RAW' }
Unhandled rejection SequelizeUniqueConstraintError: Validation error
It is creating the index with same name “addon_settings_client_key_key”, is there a way to fix this?
Thanks,
Lava
Hi @lavakumar.dukanam,
It looks like the schema.sync()
combination of the default storage of ACE on /installed
in verify-installation.js
might be duplicating the records.
What happens when you run your server as is:
// Boot the damn thing
http.createServer(app).listen(port, function(){
console.log('Add-on server running at http://' + os.hostname() + ':' + port);
// Enables auto registration/de-registration of add-ons into a host in dev mode
if (devEnv) addon.register();
});
rather then after the sync()
? Then go through the normal installation process.
For a better understanding of the flow, If you look into lib/index.js
from ACE that handles the /installed
lifecycle, you should see something like this:
self.app.post(
// installed POST handler
installUrl.path(),
// installed middleware (checks that the install event is complete and originates from an authorised host)
verifyInstallation(self),
function (req, res) {
var settings = req.body;
self.settings.set('clientInfo', settings, settings.clientKey).then(function (data) {
if (self.app.get('env') !== 'production') {
self.logger.info("Saved tenant details for " + settings.clientKey + " to database\n" + util.inspect(data));
}
self.emit('host_settings_saved', settings.clientKey, data);
res.status(204).end();
}, function (err) {
res.status(500).send(_.escape('Could not lookup stored client data for ' + settings.clientKey + ': ' + err));
});
});
the self.setting.set
part actually stores all tenant and app details for you. You might be interested in debugging that part.
Cheers,
Anne