{"action":"created","issue":{"url":"https://api.github.com/repos/c006/yii2-migration-utility/issues/13","labels_url":"https://api.github.com/repos/c006/yii2-migration-utility/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/c006/yii2-migration-utility/issues/13/comments","events_url":"https://api.github.com/repos/c006/yii2-migration-utility/issues/13/events","html_url":"https://github.com/c006/yii2-migration-utility/issues/13","id":108254418,"number":13,"title":"Multiple primary key defined","user":{"login":"ratacibernetica","id":1541791,"avatar_url":"https://avatars.githubusercontent.com/u/1541791?v=3","gravatar_id":"","url":"https://api.github.com/users/ratacibernetica","html_url":"https://github.com/ratacibernetica","followers_url":"https://api.github.com/users/ratacibernetica/followers","following_url":"https://api.github.com/users/ratacibernetica/following{/other_user}","gists_url":"https://api.github.com/users/ratacibernetica/gists{/gist_id}","starred_url":"https://api.github.com/users/ratacibernetica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ratacibernetica/subscriptions","organizations_url":"https://api.github.com/users/ratacibernetica/orgs","repos_url":"https://api.github.com/users/ratacibernetica/repos","events_url":"https://api.github.com/users/ratacibernetica/events{/privacy}","received_events_url":"https://api.github.com/users/ratacibernetica/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-25T03:20:28Z","updated_at":"2015-12-09T12:51:34Z","closed_at":null,"body":"I had a couple tables with 2 primary keys in my Schema (was using dektrium's yii2-user). \r\n\r\nThis is the code that generates the error:\r\n\r\n```php\r\n /* MYSQL */\r\n        if (!in_array('auth_assignment', $tables)) {\r\n            if ($dbType == \"mysql\") {\r\n                $this->createTable('{{%auth_assignment}}', [\r\n                    'item_name' => 'VARCHAR(64) NOT NULL',\r\n                    0 => 'PRIMARY KEY (`item_name`)',\r\n                    'user_id' => 'VARCHAR(64) NOT NULL',\r\n                    1 => 'PRIMARY KEY (`user_id`)',\r\n                    'created_at' => 'INT(11) NULL',\r\n                        ], $tableOptions_mysql);\r\n            }\r\n        }\r\n```\r\n\r\nSolved it by changing it to:\r\n```php\r\n/* MYSQL */\r\n        if (!in_array('auth_assignment', $tables)) {\r\n            if ($dbType == \"mysql\") {\r\n                $this->createTable('{{%auth_assignment}}', [\r\n                    'item_name' => 'VARCHAR(64) NOT NULL',\r\n                    'user_id' => 'VARCHAR(64) NOT NULL',\r\n                    'created_at' => 'INT(11) NULL',\r\n                        ], $tableOptions_mysql);\r\n                $this->addPrimaryKey(\r\n                                     'auth_assignment_pk',\r\n                                    'auth_assignment',\r\n                                    ['item_name','user_id']\r\n                          );\r\n            }\r\n        }\r\n```\r\n\r\nOther than that, everything worked fine!\r\n\r\nGreat plugin, thanks!"},"comment":{"url":"https://api.github.com/repos/c006/yii2-migration-utility/issues/comments/163220009","html_url":"https://github.com/c006/yii2-migration-utility/issues/13#issuecomment-163220009","issue_url":"https://api.github.com/repos/c006/yii2-migration-utility/issues/13","id":163220009,"user":{"login":"alligator77","id":6526798,"avatar_url":"https://avatars.githubusercontent.com/u/6526798?v=3","gravatar_id":"","url":"https://api.github.com/users/alligator77","html_url":"https://github.com/alligator77","followers_url":"https://api.github.com/users/alligator77/followers","following_url":"https://api.github.com/users/alligator77/following{/other_user}","gists_url":"https://api.github.com/users/alligator77/gists{/gist_id}","starred_url":"https://api.github.com/users/alligator77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alligator77/subscriptions","organizations_url":"https://api.github.com/users/alligator77/orgs","repos_url":"https://api.github.com/users/alligator77/repos","events_url":"https://api.github.com/users/alligator77/events{/privacy}","received_events_url":"https://api.github.com/users/alligator77/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T12:51:34Z","updated_at":"2015-12-09T12:51:34Z","body":"or change source in DefaultController.php in line 90\r\n```php\r\n$k = 0;\r\n                    foreach ($columns->columns as $column) {\r\n                        $appUtility = new AppUtility($column, $dbType);\r\n                        $output->addStr($appUtility->string . \"',\");\r\n                        if ($column->isPrimaryKey) {\r\n                            $output->addStr($k . \" => 'PRIMARY KEY (`\" . $column->name . \"`)',\");\r\n                        }\r\n                        $k++;\r\n                    }\r\n```\r\nto\r\n```php\r\n$k = 0; $pk = false;\r\n                    foreach ($columns->columns as $column) {\r\n                        $appUtility = new AppUtility($column, $dbType);\r\n                        $output->addStr($appUtility->string . \"',\");\r\n                        if ($column->isPrimaryKey && !$pk) {\r\n                            $output->addStr($k . \" => 'PRIMARY KEY (`\" . $column->name . \"`)',\");\r\n                            $pk = true;\r\n                        }\r\n                        elseif ($column->isPrimaryKey && $pk)\r\n                            $output->addStr($k . \" => 'KEY (`\" . $column->name . \"`)',\");\r\n\r\n                        $k++;\r\n\r\n                    }\r\n```"}}