{"action":"closed","issue":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/27732","repository_url":"https://api.github.com/repos/cockroachdb/cockroach","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/27732/labels{/name}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/27732/comments","events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/27732/events","html_url":"https://github.com/cockroachdb/cockroach/issues/27732","id":342522958,"node_id":"MDU6SXNzdWUzNDI1MjI5NTg=","number":27732,"title":"sql: a new foreign key column cannot be added in a single transaction","user":{"login":"zacps","id":9827696,"node_id":"MDQ6VXNlcjk4Mjc2OTY=","avatar_url":"https://avatars3.githubusercontent.com/u/9827696?v=4","gravatar_id":"","url":"https://api.github.com/users/zacps","html_url":"https://github.com/zacps","followers_url":"https://api.github.com/users/zacps/followers","following_url":"https://api.github.com/users/zacps/following{/other_user}","gists_url":"https://api.github.com/users/zacps/gists{/gist_id}","starred_url":"https://api.github.com/users/zacps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zacps/subscriptions","organizations_url":"https://api.github.com/users/zacps/orgs","repos_url":"https://api.github.com/users/zacps/repos","events_url":"https://api.github.com/users/zacps/events{/privacy}","received_events_url":"https://api.github.com/users/zacps/received_events","type":"User","site_admin":false},"labels":[{"id":912282008,"node_id":"MDU6TGFiZWw5MTIyODIwMDg=","url":"https://api.github.com/repos/cockroachdb/cockroach/labels/A-bulkio-schema-changes","name":"A-bulkio-schema-changes","color":"0e8a16","default":false},{"id":78928347,"node_id":"MDU6TGFiZWw3ODkyODM0Nw==","url":"https://api.github.com/repos/cockroachdb/cockroach/labels/C-enhancement","name":"C-enhancement","color":"c5def5","default":false},{"id":469980185,"node_id":"MDU6TGFiZWw0Njk5ODAxODU=","url":"https://api.github.com/repos/cockroachdb/cockroach/labels/S-3-ux-surprise","name":"S-3-ux-surprise","color":"f07700","default":false}],"state":"closed","locked":false,"assignee":{"login":"vivekmenezes","id":11774212,"node_id":"MDQ6VXNlcjExNzc0MjEy","avatar_url":"https://avatars1.githubusercontent.com/u/11774212?v=4","gravatar_id":"","url":"https://api.github.com/users/vivekmenezes","html_url":"https://github.com/vivekmenezes","followers_url":"https://api.github.com/users/vivekmenezes/followers","following_url":"https://api.github.com/users/vivekmenezes/following{/other_user}","gists_url":"https://api.github.com/users/vivekmenezes/gists{/gist_id}","starred_url":"https://api.github.com/users/vivekmenezes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vivekmenezes/subscriptions","organizations_url":"https://api.github.com/users/vivekmenezes/orgs","repos_url":"https://api.github.com/users/vivekmenezes/repos","events_url":"https://api.github.com/users/vivekmenezes/events{/privacy}","received_events_url":"https://api.github.com/users/vivekmenezes/received_events","type":"User","site_admin":false},"assignees":[{"login":"vivekmenezes","id":11774212,"node_id":"MDQ6VXNlcjExNzc0MjEy","avatar_url":"https://avatars1.githubusercontent.com/u/11774212?v=4","gravatar_id":"","url":"https://api.github.com/users/vivekmenezes","html_url":"https://github.com/vivekmenezes","followers_url":"https://api.github.com/users/vivekmenezes/followers","following_url":"https://api.github.com/users/vivekmenezes/following{/other_user}","gists_url":"https://api.github.com/users/vivekmenezes/gists{/gist_id}","starred_url":"https://api.github.com/users/vivekmenezes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vivekmenezes/subscriptions","organizations_url":"https://api.github.com/users/vivekmenezes/orgs","repos_url":"https://api.github.com/users/vivekmenezes/repos","events_url":"https://api.github.com/users/vivekmenezes/events{/privacy}","received_events_url":"https://api.github.com/users/vivekmenezes/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2018-07-18T23:10:34Z","updated_at":"2018-07-23T16:51:24Z","closed_at":"2018-07-23T16:51:24Z","author_association":"NONE","body":"**Bug report/Feature request**\r\n\r\nA foreign key constraint cannot be added in the same transaction as the column:\r\n\r\n```sql\r\nCREATE TABLE a(id INTEGER PRIMARY KEY);\r\nCREATE TABLE b(id INTEGER PRIMARY KEY);\r\n\r\nBEGIN TRANSACTION;\r\nALTER TABLE a ADD COLUMN ab INTEGER;\r\nCREATE INDEX \"x\" ON a(ab);\r\nALTER TABLE a ADD CONSTRAINT fk_ab_refs_b FOREIGN KEY (ab) REFERENCES b(id);\r\nCOMMIT;\r\n\r\n-- pq: column \"ab\" does not exist\r\n```\r\n\r\nWorkaround: Don't use a transaction.\r\nLimitations: Invalid values could be inserted into the table before the constraint can be applied.\r\n\r\nVersion: 2.0.1\r\n\r\n\r\n"}}
{"actor":{"display_login":"vivekmenezes"}}