{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-connector-mysql/issues/80","labels_url":"https://api.github.com/repos/strongloop/loopback-connector-mysql/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-connector-mysql/issues/80/comments","events_url":"https://api.github.com/repos/strongloop/loopback-connector-mysql/issues/80/events","html_url":"https://github.com/strongloop/loopback-connector-mysql/issues/80","id":60079948,"number":80,"title":"Error in creating multi-column indexes from JSON","user":{"login":"saystone","id":114876,"avatar_url":"https://avatars.githubusercontent.com/u/114876?v=3","gravatar_id":"","url":"https://api.github.com/users/saystone","html_url":"https://github.com/saystone","followers_url":"https://api.github.com/users/saystone/followers","following_url":"https://api.github.com/users/saystone/following{/other_user}","gists_url":"https://api.github.com/users/saystone/gists{/gist_id}","starred_url":"https://api.github.com/users/saystone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saystone/subscriptions","organizations_url":"https://api.github.com/users/saystone/orgs","repos_url":"https://api.github.com/users/saystone/repos","events_url":"https://api.github.com/users/saystone/events{/privacy}","received_events_url":"https://api.github.com/users/saystone/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-06T09:45:22Z","updated_at":"2015-07-13T17:35:44Z","closed_at":null,"body":"Hello!\r\n\r\n```\r\n// tag-map.json\r\n{\r\n  \"name\": \"TagMap\",\r\n  \"base\": \"PersistedModel\",\r\n  \"idInjection\": true,\r\n  \"properties\": {\r\n    \"fripId\": {\r\n      \"type\": \"number\",\r\n      \"required\": true\r\n    },\r\n    \"tagId\": {\r\n      \"type\": \"number\",\r\n      \"required\": true\r\n    }\r\n  },\r\n  \"indexes\": {\r\n    \"fripId_tagId_index\": {\r\n      \"keys\": {\r\n        \"fripId\": 1,\r\n        \"tagId\": 1\r\n      }\r\n    }\r\n  },\r\n...relations, acls, ...\r\n}\r\n```\r\n```\r\n// autoupdate.js\r\nvar app = require('./server');\r\nvar dataSource = app.dataSources.db;\r\ndataSource.autoupdate(['TagMap'], function(err) {\r\n  if (err) {\r\n    throw err;\r\n  } else {\r\n    dataSource.disconnect();\r\n  }\r\n});\r\n```\r\n```\r\n$ node ./server/autoupdate.js\r\n```\r\nIt throws following error:\r\n```\r\nError: ER_KEY_COLUMN_DOES_NOT_EXITS: Key column 'undefined' doesn't exist in table\r\n```\r\nSo i'm trying to logging query:\r\n```\r\nALTER TABLE `TagMap` ADD  INDEX  `fripId_tagId_index` (undefined)\r\n```\r\nI referenced this documentation:\r\nhttp://docs.strongloop.com/display/public/LB/Model+definition+JSON+file\r\nBut this code seems to be different:\r\nhttps://github.com/strongloop/loopback-connector-mysql/blob/master/lib/mysql.js#L884-L904\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-connector-mysql/issues/comments/121001094","html_url":"https://github.com/strongloop/loopback-connector-mysql/issues/80#issuecomment-121001094","issue_url":"https://api.github.com/repos/strongloop/loopback-connector-mysql/issues/80","id":121001094,"user":{"login":"wrensburg","id":1156185,"avatar_url":"https://avatars.githubusercontent.com/u/1156185?v=3","gravatar_id":"","url":"https://api.github.com/users/wrensburg","html_url":"https://github.com/wrensburg","followers_url":"https://api.github.com/users/wrensburg/followers","following_url":"https://api.github.com/users/wrensburg/following{/other_user}","gists_url":"https://api.github.com/users/wrensburg/gists{/gist_id}","starred_url":"https://api.github.com/users/wrensburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wrensburg/subscriptions","organizations_url":"https://api.github.com/users/wrensburg/orgs","repos_url":"https://api.github.com/users/wrensburg/repos","events_url":"https://api.github.com/users/wrensburg/events{/privacy}","received_events_url":"https://api.github.com/users/wrensburg/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T17:35:44Z","updated_at":"2015-07-13T17:35:44Z","body":"Found so many bugs with indexes and mysql. For this specific use case, I found a work around (not documented). Convert your`indexes` property above to use `columns`, rather than `keys`, like this..\r\n\r\n```\r\n\"indexes\": {\r\n    \"fripId_tagId_index\": {\r\n      \"columns\": \"fripId, tagId\"\r\n    }\r\n  }\r\n```"}}