{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/10859","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/10859/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/10859/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/10859/events","html_url":"https://github.com/yiisoft/yii2/issues/10859","id":133753811,"number":10859,"title":"Update $typeMap for MySQL","user":{"login":"gemini1389","id":6113770,"avatar_url":"https://avatars.githubusercontent.com/u/6113770?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini1389","html_url":"https://github.com/gemini1389","followers_url":"https://api.github.com/users/gemini1389/followers","following_url":"https://api.github.com/users/gemini1389/following{/other_user}","gists_url":"https://api.github.com/users/gemini1389/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini1389/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini1389/subscriptions","organizations_url":"https://api.github.com/users/gemini1389/orgs","repos_url":"https://api.github.com/users/gemini1389/repos","events_url":"https://api.github.com/users/gemini1389/events{/privacy}","received_events_url":"https://api.github.com/users/gemini1389/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:need%20more%20info","name":"status:need more info","color":"d4c5f9"},{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:under%20discussion","name":"status:under discussion","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-15T16:15:37Z","updated_at":"2016-02-16T10:11:47Z","closed_at":"2016-02-15T16:31:35Z","body":"In version 2.0.7 for migration was introduced unsigned(), and therefore I propose to update some values in $typeMap for MySQL.\r\nhttps://github.com/yiisoft/yii2/blob/master/framework/db/mysql/QueryBuilder.php#L25\r\n```php\r\nSchema::TYPE_BIGPK => 'bigint NOT NULL AUTO_INCREMENT PRIMARY KEY',\r\nSchema::TYPE_STRING => 'varchar',\r\nSchema::TYPE_SMALLINT => 'smallint',\r\nSchema::TYPE_INTEGER => 'int',\r\nSchema::TYPE_BIGINT => 'bigint',\r\n```\r\n\r\nand propose to replace TYPE_PK, because the PK in most cases greater than 0:\r\n```php\r\nSchema::TYPE_PK => 'int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY',\r\nSchema::TYPE_BIGPK => 'bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY',\r\n```"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/184608865","html_url":"https://github.com/yiisoft/yii2/issues/10859#issuecomment-184608865","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/10859","id":184608865,"user":{"login":"gemini1389","id":6113770,"avatar_url":"https://avatars.githubusercontent.com/u/6113770?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini1389","html_url":"https://github.com/gemini1389","followers_url":"https://api.github.com/users/gemini1389/followers","following_url":"https://api.github.com/users/gemini1389/following{/other_user}","gists_url":"https://api.github.com/users/gemini1389/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini1389/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini1389/subscriptions","organizations_url":"https://api.github.com/users/gemini1389/orgs","repos_url":"https://api.github.com/users/gemini1389/repos","events_url":"https://api.github.com/users/gemini1389/events{/privacy}","received_events_url":"https://api.github.com/users/gemini1389/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T10:11:47Z","updated_at":"2016-02-16T10:11:47Z","body":"Мені здається, що не має вплинути. Наприклад, метод [Migration::addColumn()](https://github.com/yiisoft/yii2/blob/master/framework/db/Migration.php#L309)\r\n```php\r\n$this->addColumn('table', 'column', 'int(11)');\r\n$this->addColumn('table', 'column', $this->integer());\r\n$this->addColumn('table', 'column', Schema::TYPE_INTEGER);\r\n```\r\nПерший варіант - це написані нами особисто параметри, які пройдуть через реплейс.\r\nДругий варіант - параметри, які будуть згенеровані фреймворком, але теж пройдуть через реплейс, так як попадуть до [QueryBuilder::getColumnType()](https://github.com/yiisoft/yii2/blob/master/framework/db/QueryBuilder.php#L608) вже у вигляді рядку.\r\nТретій вариант - не дійде до реплейса, так як це ключ у массиві [$typeMap](https://github.com/yiisoft/yii2/blob/master/framework/db/mysql/QueryBuilder.php#L25).\r\n\r\nПравда, якщо правильно зрозумів код, то для unsigned є тільки такі варіанти використання:\r\n```php\r\n$this->addColumn('table', 'column', 'int(10) unsigned');\r\n$this->addColumn('table', 'column', $this->integer()->unsigned());\r\n```\r\n\r\nЧесно признаюсь, не тестував написаний код, суджу тільки по коду фреймворка."}}