{"action":"opened","issue":{"url":"https://api.github.com/repos/berkaroad/saashard/issues/12","repository_url":"https://api.github.com/repos/berkaroad/saashard","labels_url":"https://api.github.com/repos/berkaroad/saashard/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/berkaroad/saashard/issues/12/comments","events_url":"https://api.github.com/repos/berkaroad/saashard/issues/12/events","html_url":"https://github.com/berkaroad/saashard/issues/12","id":181756425,"number":12,"title":"创建表时，报Foreign key constraint is incorrectly formed","user":{"login":"berkaroad","id":229872,"avatar_url":"https://avatars.githubusercontent.com/u/229872?v=3","gravatar_id":"","url":"https://api.github.com/users/berkaroad","html_url":"https://github.com/berkaroad","followers_url":"https://api.github.com/users/berkaroad/followers","following_url":"https://api.github.com/users/berkaroad/following{/other_user}","gists_url":"https://api.github.com/users/berkaroad/gists{/gist_id}","starred_url":"https://api.github.com/users/berkaroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkaroad/subscriptions","organizations_url":"https://api.github.com/users/berkaroad/orgs","repos_url":"https://api.github.com/users/berkaroad/repos","events_url":"https://api.github.com/users/berkaroad/events{/privacy}","received_events_url":"https://api.github.com/users/berkaroad/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/berkaroad/saashard/labels/bug","name":"bug","color":"ee0701"}],"state":"open","locked":false,"assignee":{"login":"berkaroad","id":229872,"avatar_url":"https://avatars.githubusercontent.com/u/229872?v=3","gravatar_id":"","url":"https://api.github.com/users/berkaroad","html_url":"https://github.com/berkaroad","followers_url":"https://api.github.com/users/berkaroad/followers","following_url":"https://api.github.com/users/berkaroad/following{/other_user}","gists_url":"https://api.github.com/users/berkaroad/gists{/gist_id}","starred_url":"https://api.github.com/users/berkaroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkaroad/subscriptions","organizations_url":"https://api.github.com/users/berkaroad/orgs","repos_url":"https://api.github.com/users/berkaroad/repos","events_url":"https://api.github.com/users/berkaroad/events{/privacy}","received_events_url":"https://api.github.com/users/berkaroad/received_events","type":"User","site_admin":false},"assignees":[{"login":"berkaroad","id":229872,"avatar_url":"https://avatars.githubusercontent.com/u/229872?v=3","gravatar_id":"","url":"https://api.github.com/users/berkaroad","html_url":"https://github.com/berkaroad","followers_url":"https://api.github.com/users/berkaroad/followers","following_url":"https://api.github.com/users/berkaroad/following{/other_user}","gists_url":"https://api.github.com/users/berkaroad/gists{/gist_id}","starred_url":"https://api.github.com/users/berkaroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berkaroad/subscriptions","organizations_url":"https://api.github.com/users/berkaroad/orgs","repos_url":"https://api.github.com/users/berkaroad/repos","events_url":"https://api.github.com/users/berkaroad/events{/privacy}","received_events_url":"https://api.github.com/users/berkaroad/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2016-10-07T20:05:11Z","updated_at":"2016-10-07T20:05:11Z","closed_at":null,"body":"使用的mysql版本为mariadb 10.1.18\r\n\r\n```\r\nexplain CREATE TABLE `sub_category` (\r\n  `id` INT NOT NULL COMMENT '',\r\n  `tenant_id` INT NOT NULL COMMENT '',\r\n  `top_category_id` INT NOT NULL COMMENT '',\r\n  `code` VARCHAR(20) NOT NULL COMMENT '',\r\n  `name` VARCHAR(50) NOT NULL COMMENT '',\r\n  `description` VARCHAR(200) NULL COMMENT '',\r\n  PRIMARY KEY (`id`),\r\n  UNIQUE INDEX `code_UNIQUE` (`tenant_id` ASC, `code` ASC),\r\n  UNIQUE INDEX `name_UNIQUE` (`tenant_id` ASC, `name` ASC),\r\n  CONSTRAINT `fk_sub_category_top_category_id` FOREIGN KEY (`top_category_id`) references `top_category`(`id`)\r\n);\r\n```\r\n执行结果的plan_sql为：\r\n```\r\nexplain CREATE TABLE `sub_category` (\r\n  `id` INT NOT NULL COMMENT '',\r\n  `tenant_id` INT NOT NULL COMMENT '',\r\n  `top_category_id` INT NOT NULL COMMENT '',\r\n  `code` VARCHAR(20) NOT NULL COMMENT '',\r\n  `name` VARCHAR(50) NOT NULL COMMENT '',\r\n  `description` VARCHAR(200) NULL COMMENT '',\r\n  PRIMARY KEY (`id`),\r\n  UNIQUE INDEX `code_UNIQUE` (`tenant_id` ASC, `code` ASC),\r\n  UNIQUE INDEX `name_UNIQUE` (`tenant_id` ASC, `name` ASC),\r\n  CONSTRAINT `fk_sub_category_top_category_id` FOREIGN KEY (`top_category_id`) references `top_category`(`id`)\r\n);\r\n```"}}
{"actor":{"display_login":"berkaroad"}}