{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/migrations/issues/274","repository_url":"https://api.github.com/repos/cakephp/migrations","labels_url":"https://api.github.com/repos/cakephp/migrations/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/migrations/issues/274/comments","events_url":"https://api.github.com/repos/cakephp/migrations/issues/274/events","html_url":"https://github.com/cakephp/migrations/issues/274","id":188641127,"number":274,"title":"Rolling back and applying migration leads to de-synchronization of the data structure","user":{"login":"dmromanov","id":299059,"avatar_url":"https://avatars.githubusercontent.com/u/299059?v=3","gravatar_id":"","url":"https://api.github.com/users/dmromanov","html_url":"https://github.com/dmromanov","followers_url":"https://api.github.com/users/dmromanov/followers","following_url":"https://api.github.com/users/dmromanov/following{/other_user}","gists_url":"https://api.github.com/users/dmromanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dmromanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmromanov/subscriptions","organizations_url":"https://api.github.com/users/dmromanov/orgs","repos_url":"https://api.github.com/users/dmromanov/repos","events_url":"https://api.github.com/users/dmromanov/events{/privacy}","received_events_url":"https://api.github.com/users/dmromanov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-10T22:54:39Z","updated_at":"2016-11-11T08:55:18Z","closed_at":null,"body":"This is a (multiple allowed):\r\n* [x] bug\r\n* [ ] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: `v3.3.8`\r\n* Migrations plugin version: `1.6.3`\r\n* Bake plugin version (if relevant): `1.2.8`\r\n* Database server (MySQL, SQLite, Postgres): `mysql  Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using  EditLine wrapper`\r\n* PHP Version: `PHP 7.0.8-3ubuntu3 (cli) ( NTS )`\r\n* Platform / OS: Preferably with version number\r\n\r\n### What you did\r\n1. Create two tables with a foreign key 'NO ACTION' constraint relation\r\n```sql\r\nCREATE TABLE `table_a` (\r\n  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n  `flag` integer(2) NOT NULL,\r\n  PRIMARY KEY (`id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n```\r\n\r\n2. Bake a migration file\r\n`./bin/cake bake migration_diff Test1`\r\n3. Alter table: add a default value for the 'flag' field\r\n```sql\r\nALTER TABLE `table_a`\r\nCHANGE `flag` `flag` int(2) NOT NULL DEFAULT '0' AFTER `id`;\r\n```\r\n4. Bake a new migration\r\n`./bin/cake bake migration_diff Test2`\r\n\r\n5. Roll back migration\r\n`./bin/cake bake migrations rollback`\r\n6. Migrate up\r\n`./bin/cake bake migrations migrate`\r\n\r\n### Expected Behavior\r\nExpected field 'flag' to be `int(2) default 0`\r\n\r\n### Actual Behavior\r\nField 'flag' is `int(11) default 0`\r\n\r\nCode of 'Test2' migration:\r\n```php\r\nuse Migrations\\AbstractMigration;\r\n\r\nclass Test2 extends AbstractMigration\r\n{\r\n\r\n    public function up()\r\n    {\r\n\r\n        $this->table('table_a')\r\n            ->changeColumn('flag', 'integer', [\r\n                'default' => 0,\r\n            ])\r\n            ->update();\r\n    }\r\n\r\n    public function down()\r\n    {\r\n\r\n        $this->table('table_a')\r\n            ->changeColumn('flag', 'integer', [\r\n                'default' => null,\r\n                'length' => 2,\r\n                'null' => false,\r\n            ])\r\n            ->update();\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/cakephp/migrations/issues/comments/259911106","html_url":"https://github.com/cakephp/migrations/issues/274#issuecomment-259911106","issue_url":"https://api.github.com/repos/cakephp/migrations/issues/274","id":259911106,"user":{"login":"dmromanov","id":299059,"avatar_url":"https://avatars.githubusercontent.com/u/299059?v=3","gravatar_id":"","url":"https://api.github.com/users/dmromanov","html_url":"https://github.com/dmromanov","followers_url":"https://api.github.com/users/dmromanov/followers","following_url":"https://api.github.com/users/dmromanov/following{/other_user}","gists_url":"https://api.github.com/users/dmromanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dmromanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmromanov/subscriptions","organizations_url":"https://api.github.com/users/dmromanov/orgs","repos_url":"https://api.github.com/users/dmromanov/repos","events_url":"https://api.github.com/users/dmromanov/events{/privacy}","received_events_url":"https://api.github.com/users/dmromanov/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T08:55:18Z","updated_at":"2016-11-11T08:55:18Z","body":"@thinkingmedia I've appended `Test2` migration to the issue's description."}}
{"actor":{"display_login":"dmromanov"}}