Skip to content

Autoupdate error: index or statistics already exists on table  #180

@Narrator

Description

@Narrator

I get the following message whenever I run autoupdate:

"error":{"message":"The operation failed because an index or statistics with name 'principalId_NONCLUSTERED_ASC_idx' already exists on table 'dbo.RoleMapping'.","stack":"RequestError: The operation failed because an index or statistics with name 'principalId_NONCLUSTERED_ASC_idx' already exists on table 'dbo.RoleMapping'
The table name doesn't matter, cause the error is thrown on different tables every time. The first run is fine, but whenever I kill the app and restart it, this error is thrown.

Here's the code I'm using in boot/auto-update.js

'use strict';

module.exports = function(app, done) {
  var logger = require('../../server/logger');
  var log = logger.child({module: 'auto-update'});

  var mssql = app.dataSources.mssql;

  mssql.autoupdate(function(err) {
    if (err) {
      log.error({error: err}, 'Error autoupdating DB');
      return done(err);
    }
    log.info('Database updation complete.');
    done();
  });
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions