Skip to content

Show indexes query on Postgres fails to return functional indexes #3911

@johnnncodes

Description

@johnnncodes

Model:

module.exports = function(sequelize, DataTypes) {
  var Model = sequelize.define('Company', {
    name: {
      type: DataTypes.STRING,
      unique: true
    }
  }, {
    indexes: [
      { name: 'unique_name', unique: true, fields: [sequelize.fn('lower', sequelize.col('name'))] }
    ]
  });

  return Model;
};

It works when the database is empty. But when I stop the server and then run it again. It throws this error:

Possibly unhandled SequelizeDatabaseError: relation "unique_name" already exists
    at module.exports.Query.formatError (/Users/johnkevinmbasco/webapps/helpdesk/node_modules/sequelize/lib/dialects/postgres/query.js:415:16)
    at null.<anonymous> (/Users/johnkevinmbasco/webapps/helpdesk/node_modules/sequelize/lib/dialects/postgres/query.js:110:21)
    at emit (events.js:95:17)
    at Query.handleError (/Users/johnkevinmbasco/webapps/helpdesk/node_modules/pg/lib/query.js:99:8)
    at null.<anonymous> (/Users/johnkevinmbasco/webapps/helpdesk/node_modules/pg/lib/client.js:166:26)
    at emit (events.js:95:17)
    at Socket.<anonymous> (/Users/johnkevinmbasco/webapps/helpdesk/node_modules/pg/lib/connection.js:109:12)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:764:14)
    at Socket.emit (events.js:92:17)

The contents of my /bin/www file is similar to this - https://github.com/sequelize/express-example/blob/master/bin/www

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions