{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/213542770","pull_request_review_id":150399578,"id":213542770,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzU0Mjc3MA==","diff_hunk":"@@ -994,33 +996,70 @@ def _rename_field_sql(self, table, old_field, new_field, new_type):\n             \"type\": new_type,\n         }\n \n-    def _create_fk_sql(self, model, field, suffix):\n-        from_table = model._meta.db_table\n-        from_column = field.column\n-        _, to_table = split_identifier(field.target_field.model._meta.db_table)\n-        to_column = field.target_field.column\n+    def _create_constraint_sql(self, table, name, constraint):\n+        constraint = Statement(self.sql_constraint, name=name, constraint=constraint)\n+        return Statement(self.sql_create_constraint, table=table, constraint=constraint)\n \n+    def _create_fk_sql(self, model, field, suffix):\n         def create_fk_name(*args, **kwargs):\n             return self.quote_name(self._create_index_name(*args, **kwargs))\n \n-        return Statement(\n-            self.sql_create_fk,\n-            table=Table(from_table, self.quote_name),\n-            name=ForeignKeyName(from_table, [from_column], to_table, [to_column], suffix, create_fk_name),\n-            column=Columns(from_table, [from_column], self.quote_name),\n-            to_table=Table(field.target_field.model._meta.db_table, self.quote_name),\n-            to_column=Columns(field.target_field.model._meta.db_table, [to_column], self.quote_name),\n-            deferrable=self.connection.ops.deferrable_sql(),\n+        table = Table(model._meta.db_table, self.quote_name)\n+        name = ForeignKeyName(\n+            model._meta.db_table,\n+            [field.column],\n+            split_identifier(field.target_field.model._meta.db_table)[1],\n+            [field.target_field.column],\n+            suffix,\n+            create_fk_name,\n         )\n+        column = Columns(model._meta.db_table, [field.column], self.quote_name)\n+        to_table = Table(field.target_field.model._meta.db_table, self.quote_name)\n+        to_column = Columns(field.target_field.model._meta.db_table, [field.target_field.column], self.quote_name)\n+        deferrable = self.connection.ops.deferrable_sql()\n+        if self.sql_create_fk:\n+            # XXX: Not sure if we should deprecate this path? The foreign key\n+            # creation syntax is quite standard and none of builtin backends\n+            # override this.","path":"django/db/backends/base/schema.py","position":133,"original_position":133,"commit_id":"7a2a6cde1d59598623bfb6146bdf7e986a0c8c8e","original_commit_id":"7a2a6cde1d59598623bfb6146bdf7e986a0c8c8e","user":{"login":"charettes","id":9293,"node_id":"MDQ6VXNlcjkyOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/9293?v=4","gravatar_id":"","url":"https://api.github.com/users/charettes","html_url":"https://github.com/charettes","followers_url":"https://api.github.com/users/charettes/followers","following_url":"https://api.github.com/users/charettes/following{/other_user}","gists_url":"https://api.github.com/users/charettes/gists{/gist_id}","starred_url":"https://api.github.com/users/charettes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charettes/subscriptions","organizations_url":"https://api.github.com/users/charettes/orgs","repos_url":"https://api.github.com/users/charettes/repos","events_url":"https://api.github.com/users/charettes/events{/privacy}","received_events_url":"https://api.github.com/users/charettes/received_events","type":"User","site_admin":false},"body":"I guess this will have to be addressed. There seems to be [quite a bit of overrides of `sql_create_fk`](https://github.com/search?l=Python&q=sql_create_fk&type=Code) so this will have to go through a deprecation period at least.","created_at":"2018-08-29T04:40:02Z","updated_at":"2018-08-29T04:46:32Z","html_url":"https://github.com/django/django/pull/10337#discussion_r213542770","pull_request_url":"https://api.github.com/repos/django/django/pulls/10337","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/213542770"},"html":{"href":"https://github.com/django/django/pull/10337#discussion_r213542770"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/10337"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/10337","id":210982043,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwOTgyMDQz","html_url":"https://github.com/django/django/pull/10337","diff_url":"https://github.com/django/django/pull/10337.diff","patch_url":"https://github.com/django/django/pull/10337.patch","issue_url":"https://api.github.com/repos/django/django/issues/10337","number":10337,"state":"open","locked":false,"title":"Fixed #29641 -- Added UniqueConstraint support.","user":{"login":"Ian-Foote","id":1843202,"node_id":"MDQ6VXNlcjE4NDMyMDI=","avatar_url":"https://avatars1.githubusercontent.com/u/1843202?v=4","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"body":"@charettes I've cleaned up your branch a bit. (https://github.com/django/django/pull/10271)","created_at":"2018-08-27T00:52:50Z","updated_at":"2018-08-29T04:46:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efda706e44c851f70b45045efed6be0b0402361d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/10337/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/10337/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/10337/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/7a2a6cde1d59598623bfb6146bdf7e986a0c8c8e","head":{"label":"Ian-Foote:unique-constraint","ref":"unique-constraint","sha":"7a2a6cde1d59598623bfb6146bdf7e986a0c8c8e","user":{"login":"Ian-Foote","id":1843202,"node_id":"MDQ6VXNlcjE4NDMyMDI=","avatar_url":"https://avatars1.githubusercontent.com/u/1843202?v=4","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"repo":{"id":16351410,"node_id":"MDEwOlJlcG9zaXRvcnkxNjM1MTQxMA==","name":"django","full_name":"Ian-Foote/django","owner":{"login":"Ian-Foote","id":1843202,"node_id":"MDQ6VXNlcjE4NDMyMDI=","avatar_url":"https://avatars1.githubusercontent.com/u/1843202?v=4","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ian-Foote/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/Ian-Foote/django","forks_url":"https://api.github.com/repos/Ian-Foote/django/forks","keys_url":"https://api.github.com/repos/Ian-Foote/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ian-Foote/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ian-Foote/django/teams","hooks_url":"https://api.github.com/repos/Ian-Foote/django/hooks","issue_events_url":"https://api.github.com/repos/Ian-Foote/django/issues/events{/number}","events_url":"https://api.github.com/repos/Ian-Foote/django/events","assignees_url":"https://api.github.com/repos/Ian-Foote/django/assignees{/user}","branches_url":"https://api.github.com/repos/Ian-Foote/django/branches{/branch}","tags_url":"https://api.github.com/repos/Ian-Foote/django/tags","blobs_url":"https://api.github.com/repos/Ian-Foote/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ian-Foote/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ian-Foote/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ian-Foote/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ian-Foote/django/statuses/{sha}","languages_url":"https://api.github.com/repos/Ian-Foote/django/languages","stargazers_url":"https://api.github.com/repos/Ian-Foote/django/stargazers","contributors_url":"https://api.github.com/repos/Ian-Foote/django/contributors","subscribers_url":"https://api.github.com/repos/Ian-Foote/django/subscribers","subscription_url":"https://api.github.com/repos/Ian-Foote/django/subscription","commits_url":"https://api.github.com/repos/Ian-Foote/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ian-Foote/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ian-Foote/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ian-Foote/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ian-Foote/django/contents/{+path}","compare_url":"https://api.github.com/repos/Ian-Foote/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ian-Foote/django/merges","archive_url":"https://api.github.com/repos/Ian-Foote/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ian-Foote/django/downloads","issues_url":"https://api.github.com/repos/Ian-Foote/django/issues{/number}","pulls_url":"https://api.github.com/repos/Ian-Foote/django/pulls{/number}","milestones_url":"https://api.github.com/repos/Ian-Foote/django/milestones{/number}","notifications_url":"https://api.github.com/repos/Ian-Foote/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ian-Foote/django/labels{/name}","releases_url":"https://api.github.com/repos/Ian-Foote/django/releases{/id}","deployments_url":"https://api.github.com/repos/Ian-Foote/django/deployments","created_at":"2014-01-29T16:52:51Z","updated_at":"2018-08-27T23:09:19Z","pushed_at":"2018-08-28T04:26:13Z","git_url":"git://github.com/Ian-Foote/django.git","ssh_url":"git@github.com:Ian-Foote/django.git","clone_url":"https://github.com/Ian-Foote/django.git","svn_url":"https://github.com/Ian-Foote/django","homepage":"http://www.djangoproject.com/","size":172463,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"django:master","ref":"master","sha":"76df4f35c2d732f7996aa6b8d816424c52ee0cc1","user":{"login":"django","id":27804,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3ODA0","avatar_url":"https://avatars2.githubusercontent.com/u/27804?v=4","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"repo":{"id":4164482,"node_id":"MDEwOlJlcG9zaXRvcnk0MTY0NDgy","name":"django","full_name":"django/django","owner":{"login":"django","id":27804,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3ODA0","avatar_url":"https://avatars2.githubusercontent.com/u/27804?v=4","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django/django","description":"The Web framework for perfectionists with deadlines.","fork":false,"url":"https://api.github.com/repos/django/django","forks_url":"https://api.github.com/repos/django/django/forks","keys_url":"https://api.github.com/repos/django/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django/django/teams","hooks_url":"https://api.github.com/repos/django/django/hooks","issue_events_url":"https://api.github.com/repos/django/django/issues/events{/number}","events_url":"https://api.github.com/repos/django/django/events","assignees_url":"https://api.github.com/repos/django/django/assignees{/user}","branches_url":"https://api.github.com/repos/django/django/branches{/branch}","tags_url":"https://api.github.com/repos/django/django/tags","blobs_url":"https://api.github.com/repos/django/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/django/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django/django/statuses/{sha}","languages_url":"https://api.github.com/repos/django/django/languages","stargazers_url":"https://api.github.com/repos/django/django/stargazers","contributors_url":"https://api.github.com/repos/django/django/contributors","subscribers_url":"https://api.github.com/repos/django/django/subscribers","subscription_url":"https://api.github.com/repos/django/django/subscription","commits_url":"https://api.github.com/repos/django/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/django/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/django/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/django/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/django/django/contents/{+path}","compare_url":"https://api.github.com/repos/django/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django/django/merges","archive_url":"https://api.github.com/repos/django/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django/django/downloads","issues_url":"https://api.github.com/repos/django/django/issues{/number}","pulls_url":"https://api.github.com/repos/django/django/pulls{/number}","milestones_url":"https://api.github.com/repos/django/django/milestones{/number}","notifications_url":"https://api.github.com/repos/django/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django/django/labels{/name}","releases_url":"https://api.github.com/repos/django/django/releases{/id}","deployments_url":"https://api.github.com/repos/django/django/deployments","created_at":"2012-04-28T02:47:18Z","updated_at":"2018-08-29T04:20:59Z","pushed_at":"2018-08-28T18:40:47Z","git_url":"git://github.com/django/django.git","ssh_url":"git@github.com:django/django.git","clone_url":"https://github.com/django/django.git","svn_url":"https://github.com/django/django","homepage":"https://www.djangoproject.com/","size":180968,"stargazers_count":36068,"watchers_count":36068,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15425,"mirror_url":null,"archived":false,"open_issues_count":151,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":15425,"open_issues":151,"watchers":36068,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/10337"},"html":{"href":"https://github.com/django/django/pull/10337"},"issue":{"href":"https://api.github.com/repos/django/django/issues/10337"},"comments":{"href":"https://api.github.com/repos/django/django/issues/10337/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/10337/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/10337/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/7a2a6cde1d59598623bfb6146bdf7e986a0c8c8e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"charettes"}}