{"action":"created","issue":{"url":"https://api.github.com/repos/alphagov/whitehall/issues/2043","labels_url":"https://api.github.com/repos/alphagov/whitehall/issues/2043/labels{/name}","comments_url":"https://api.github.com/repos/alphagov/whitehall/issues/2043/comments","events_url":"https://api.github.com/repos/alphagov/whitehall/issues/2043/events","html_url":"https://github.com/alphagov/whitehall/pull/2043","id":63699669,"number":2043,"title":"Add data migration to fix UUIDs in MySQL replication","user":{"login":"bradleywright","id":1516,"avatar_url":"https://avatars.githubusercontent.com/u/1516?v=3","gravatar_id":"","url":"https://api.github.com/users/bradleywright","html_url":"https://github.com/bradleywright","followers_url":"https://api.github.com/users/bradleywright/followers","following_url":"https://api.github.com/users/bradleywright/following{/other_user}","gists_url":"https://api.github.com/users/bradleywright/gists{/gist_id}","starred_url":"https://api.github.com/users/bradleywright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradleywright/subscriptions","organizations_url":"https://api.github.com/users/bradleywright/orgs","repos_url":"https://api.github.com/users/bradleywright/repos","events_url":"https://api.github.com/users/bradleywright/events{/privacy}","received_events_url":"https://api.github.com/users/bradleywright/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-23T11:22:37Z","updated_at":"2015-03-23T11:25:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/alphagov/whitehall/pulls/2043","html_url":"https://github.com/alphagov/whitehall/pull/2043","diff_url":"https://github.com/alphagov/whitehall/pull/2043.diff","patch_url":"https://github.com/alphagov/whitehall/pull/2043.patch"},"body":"The bare `uuid` function call in MySQL isn't replication safe when performing STATEMENT-level binary replication:\r\n\r\nhttp://dev.mysql.com/doc/refman/5.1/en/replication-rbr-safe-unsafe.html\r\n\r\nIn a previous migration, we batch-updated several models using this function to insert `content_id` values. When these migrations replicated to our backup and read-only slaves, the UUIDs became wrong because of the replication safety issue.\r\n\r\nThis means that currently our backups aren't current with production as the `content_id` values differ.\r\n\r\nThis commit fixes that by running a data migration on the master machine which:\r\n\r\n1. Grabs the `content_id` in Ruby-land, avoiding replication issues\r\n2. Forcing an `UPDATE` statement to run using `update_columns` call\r\n3. Once this has run, the `UPDATE` statements will replicate to the\r\n   slaves containing the correct strings, which will synchronise the\r\n   slave values with the master.\r\n\r\nThe migrations themselves were future-proofed in 4864e94e58f65900fc2b089f966aad75f74ba6c3."},"comment":{"url":"https://api.github.com/repos/alphagov/whitehall/issues/comments/84956636","html_url":"https://github.com/alphagov/whitehall/pull/2043#issuecomment-84956636","issue_url":"https://api.github.com/repos/alphagov/whitehall/issues/2043","id":84956636,"user":{"login":"alext","id":5560,"avatar_url":"https://avatars.githubusercontent.com/u/5560?v=3","gravatar_id":"","url":"https://api.github.com/users/alext","html_url":"https://github.com/alext","followers_url":"https://api.github.com/users/alext/followers","following_url":"https://api.github.com/users/alext/following{/other_user}","gists_url":"https://api.github.com/users/alext/gists{/gist_id}","starred_url":"https://api.github.com/users/alext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alext/subscriptions","organizations_url":"https://api.github.com/users/alext/orgs","repos_url":"https://api.github.com/users/alext/repos","events_url":"https://api.github.com/users/alext/events{/privacy}","received_events_url":"https://api.github.com/users/alext/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T11:25:10Z","updated_at":"2015-03-23T11:25:10Z","body":":+1: looks good to me."}}