Skip to content

Restarting sequelize app with indexes causes ER_DUP_KEYNAME #2162

@mlegenhausen

Description

@mlegenhausen

Example:

var Sequelize = require('sequelize');

var sequelize = new Sequelize('sequelize-test', 'root', '');

var Model = sequelize.define('Model', {
    key: Sequelize.STRING
}, {
    indexes: [
        {
            name: 'key-index',
            fields: ['key']
        }
    ]
});

sequelize.sync();

First start everything works fine. Starting the app again generates following error:

Executing (undefined): CREATE TABLE IF NOT EXISTS `Models` (`id` INTEGER NOT NULL auto_increment , `key` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (undefined): CREATE INDEX `key-index` ON `Models` (`key`)
Possibly unhandled Error: ER_DUP_KEYNAME: Duplicate key name 'key-index'

Tested with current master version.

Metadata

Metadata

Assignees

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