{"action":"created","issue":{"url":"https://api.github.com/repos/gocardless/statesman/issues/157","labels_url":"https://api.github.com/repos/gocardless/statesman/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/gocardless/statesman/issues/157/comments","events_url":"https://api.github.com/repos/gocardless/statesman/issues/157/events","html_url":"https://github.com/gocardless/statesman/issues/157","id":67921921,"number":157,"title":"[MySQL] Uniqueness constraint on most recent index","user":{"login":"robinjfisher","id":93339,"avatar_url":"https://avatars.githubusercontent.com/u/93339?v=3","gravatar_id":"","url":"https://api.github.com/users/robinjfisher","html_url":"https://github.com/robinjfisher","followers_url":"https://api.github.com/users/robinjfisher/followers","following_url":"https://api.github.com/users/robinjfisher/following{/other_user}","gists_url":"https://api.github.com/users/robinjfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/robinjfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robinjfisher/subscriptions","organizations_url":"https://api.github.com/users/robinjfisher/orgs","repos_url":"https://api.github.com/users/robinjfisher/repos","events_url":"https://api.github.com/users/robinjfisher/events{/privacy}","received_events_url":"https://api.github.com/users/robinjfisher/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-12T14:28:41Z","updated_at":"2015-04-12T15:44:54Z","closed_at":null,"body":"Hi,\r\n\r\nPerhaps I'm missing something but I'm struggling to use more than 3 states in light of the uniqueness constraint on the most recent index.  As I understand it, the index key is constructed from the id of the model and the boolean flag from the most_recent column.  My model relates to an absence, and I have the following states:\r\n\r\nUnapproved (default state)\r\nProvisionally Approved (sets most_recent to 1 giving key id-1)\r\nApproved (sets most_recent to 1 giving 2 keys: id-0 for the original transition and id-1 for the transition to approved)\r\nCancelled - fails on transition here because a duplicate index key is created.\r\n\r\nIs this the intended behaviour?  For the time being I've dropped the uniqueness constraint on the index but I understand this will then stop the most_recent column being used for queries.\r\n\r\nThanks\r\n\r\nRobin"},"comment":{"url":"https://api.github.com/repos/gocardless/statesman/issues/comments/92082431","html_url":"https://github.com/gocardless/statesman/issues/157#issuecomment-92082431","issue_url":"https://api.github.com/repos/gocardless/statesman/issues/157","id":92082431,"user":{"login":"isaacseymour","id":1834049,"avatar_url":"https://avatars.githubusercontent.com/u/1834049?v=3","gravatar_id":"","url":"https://api.github.com/users/isaacseymour","html_url":"https://github.com/isaacseymour","followers_url":"https://api.github.com/users/isaacseymour/followers","following_url":"https://api.github.com/users/isaacseymour/following{/other_user}","gists_url":"https://api.github.com/users/isaacseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacseymour/subscriptions","organizations_url":"https://api.github.com/users/isaacseymour/orgs","repos_url":"https://api.github.com/users/isaacseymour/repos","events_url":"https://api.github.com/users/isaacseymour/events{/privacy}","received_events_url":"https://api.github.com/users/isaacseymour/received_events","type":"User","site_admin":false},"created_at":"2015-04-12T15:44:54Z","updated_at":"2015-04-12T15:44:54Z","body":"https://github.com/rails/rails/issues/18106\r\n\r\nLooks a lot like MySQL doesn't support partial indexes :("}}