{"action":"created","issue":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/1194","repository_url":"https://api.github.com/repos/jinzhu/gorm","labels_url":"https://api.github.com/repos/jinzhu/gorm/issues/1194/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/gorm/issues/1194/comments","events_url":"https://api.github.com/repos/jinzhu/gorm/issues/1194/events","html_url":"https://github.com/jinzhu/gorm/issues/1194","id":178333806,"number":1194,"title":"Many to many table with self referencing field","user":{"login":"iyedg","id":2780980,"avatar_url":"https://avatars.githubusercontent.com/u/2780980?v=3","gravatar_id":"","url":"https://api.github.com/users/iyedg","html_url":"https://github.com/iyedg","followers_url":"https://api.github.com/users/iyedg/followers","following_url":"https://api.github.com/users/iyedg/following{/other_user}","gists_url":"https://api.github.com/users/iyedg/gists{/gist_id}","starred_url":"https://api.github.com/users/iyedg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyedg/subscriptions","organizations_url":"https://api.github.com/users/iyedg/orgs","repos_url":"https://api.github.com/users/iyedg/repos","events_url":"https://api.github.com/users/iyedg/events{/privacy}","received_events_url":"https://api.github.com/users/iyedg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-21T12:34:38Z","updated_at":"2016-09-21T14:16:31Z","closed_at":null,"body":"I have this model that represents a course, which might have many courses as prerequisites and be a prerequisite of many courses\r\n\r\n```\r\ntype Course struct {\r\n\tgorm.Model\r\n\tName          string\r\n\tPrerequisites []Course `gorm:\"many2many:course_prerequisite\"`\r\n}\r\n```\r\n\r\nthis code raises an error\r\n\r\n`duplicate column name: course_id`\r\n\r\nthe logger shows that the generated SQL is as follows:\r\n\r\n`CREATE TABLE \"course_prerequisite\" (\"course_id\" integer,\"course_id\" integer, PRIMARY KEY (\"course_id\",\"course_id\")) `\r\n\r\nIs there a way to rename one of the columns or any other way around this error ?\r\n"},"comment":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/comments/248625620","html_url":"https://github.com/jinzhu/gorm/issues/1194#issuecomment-248625620","issue_url":"https://api.github.com/repos/jinzhu/gorm/issues/1194","id":248625620,"user":{"login":"iyedg","id":2780980,"avatar_url":"https://avatars.githubusercontent.com/u/2780980?v=3","gravatar_id":"","url":"https://api.github.com/users/iyedg","html_url":"https://github.com/iyedg","followers_url":"https://api.github.com/users/iyedg/followers","following_url":"https://api.github.com/users/iyedg/following{/other_user}","gists_url":"https://api.github.com/users/iyedg/gists{/gist_id}","starred_url":"https://api.github.com/users/iyedg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyedg/subscriptions","organizations_url":"https://api.github.com/users/iyedg/orgs","repos_url":"https://api.github.com/users/iyedg/repos","events_url":"https://api.github.com/users/iyedg/events{/privacy}","received_events_url":"https://api.github.com/users/iyedg/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T14:16:31Z","updated_at":"2016-09-21T14:16:31Z","body":"I figured it is bad data structure, but I could not come up with a logical way to model this relationship. It is a tree where all the nodes have the same type, therefore `Prerequisites` must be of type `Course`"}}
{"actor":{"display_login":"iyedg"}}