{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/3413","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/3413/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/3413/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/3413/events","html_url":"https://github.com/sequelize/sequelize/issues/3413","id":64588266,"number":3413,"title":"Secondary indexes not using fieldname mappings","user":{"login":"quiddle","id":976237,"avatar_url":"https://avatars.githubusercontent.com/u/976237?v=3","gravatar_id":"","url":"https://api.github.com/users/quiddle","html_url":"https://github.com/quiddle","followers_url":"https://api.github.com/users/quiddle/followers","following_url":"https://api.github.com/users/quiddle/following{/other_user}","gists_url":"https://api.github.com/users/quiddle/gists{/gist_id}","starred_url":"https://api.github.com/users/quiddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quiddle/subscriptions","organizations_url":"https://api.github.com/users/quiddle/orgs","repos_url":"https://api.github.com/users/quiddle/repos","events_url":"https://api.github.com/users/quiddle/events{/privacy}","received_events_url":"https://api.github.com/users/quiddle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-26T17:29:26Z","updated_at":"2015-03-26T19:19:35Z","closed_at":null,"body":"If I define a model like this:\r\n```javascript\r\n sequelize.define('campaignRecipient',\r\n    {\r\n      status: {\r\n        field:        'mail_status',\r\n        type:         types.ENUM('pending','sent','cancel'),\r\n        allowNull:    false,\r\n        defaultValue: 'pending'\r\n      }\r\n    },\r\n    {\r\n      indexes: [\r\n        { fields: ['status'] }\r\n      ],\r\n    }\r\n  );\r\n```\r\nand then call `db.models.campaignRecipient.sync()`, I'll get the error `ER_KEY_COLUMN_DOES_NOT_EXITS: Key column 'status' doesn't exist in table`. It works fine using `mail_status` in the `indexes` array."},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/86678435","html_url":"https://github.com/sequelize/sequelize/issues/3413#issuecomment-86678435","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/3413","id":86678435,"user":{"login":"janmeier","id":1210224,"avatar_url":"https://avatars.githubusercontent.com/u/1210224?v=3","gravatar_id":"","url":"https://api.github.com/users/janmeier","html_url":"https://github.com/janmeier","followers_url":"https://api.github.com/users/janmeier/followers","following_url":"https://api.github.com/users/janmeier/following{/other_user}","gists_url":"https://api.github.com/users/janmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/janmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janmeier/subscriptions","organizations_url":"https://api.github.com/users/janmeier/orgs","repos_url":"https://api.github.com/users/janmeier/repos","events_url":"https://api.github.com/users/janmeier/events{/privacy}","received_events_url":"https://api.github.com/users/janmeier/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T19:19:35Z","updated_at":"2015-03-26T19:19:35Z","body":"Well since indexes are defined at model definition time I think its a reasonable constraint to only use actual fields names"}}