{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/1234","repository_url":"https://api.github.com/repos/tgriesser/knex","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/1234/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1234/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/1234/events","html_url":"https://github.com/tgriesser/knex/issues/1234","id":136960101,"number":1234,"title":"Knex migration fails to migrate database","user":{"login":"teckays","id":2588178,"avatar_url":"https://avatars.githubusercontent.com/u/2588178?v=3","gravatar_id":"","url":"https://api.github.com/users/teckays","html_url":"https://github.com/teckays","followers_url":"https://api.github.com/users/teckays/followers","following_url":"https://api.github.com/users/teckays/following{/other_user}","gists_url":"https://api.github.com/users/teckays/gists{/gist_id}","starred_url":"https://api.github.com/users/teckays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teckays/subscriptions","organizations_url":"https://api.github.com/users/teckays/orgs","repos_url":"https://api.github.com/users/teckays/repos","events_url":"https://api.github.com/users/teckays/events{/privacy}","received_events_url":"https://api.github.com/users/teckays/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-27T19:46:29Z","updated_at":"2016-02-28T19:20:12Z","closed_at":null,"body":"`knex migrate:latest` throws an error:\r\n\r\n```\r\nKnex:warning - migrations failed with error: create table \"table_name\" (\"id\" serial primary key, \"email\" varchar(255), \"createdDate\" timestamptz) - relation \"table_name\" already exists\r\nerror: create table \"table_name\" (\"id\" serial primary key, \"email\" varchar(255), \"createdDate\" timestamptz) - relation \"table_name\" already exists\r\n```\r\n\r\nIt's true that the table exists, but doesn't it has to drop before running the migration?\r\n\r\n```\r\nexports.up = function(knex, Promise) {\r\n  return Promise.all([\r\n    knex.schema.createTable('table_name', function(table){\r\n      table.increments('id').primary();\r\n      table.string('email').unique();\r\n      table.dateTime('createdDate');\r\n    }),\r\n  ])\r\n};\r\n\r\nexports.down = function(knex, Promise) {\r\n  return Promise.all([\r\n    knex.schema.dropTableIfExists('table_name')\r\n  ])\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/189925680","html_url":"https://github.com/tgriesser/knex/issues/1234#issuecomment-189925680","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/1234","id":189925680,"user":{"login":"teckays","id":2588178,"avatar_url":"https://avatars.githubusercontent.com/u/2588178?v=3","gravatar_id":"","url":"https://api.github.com/users/teckays","html_url":"https://github.com/teckays","followers_url":"https://api.github.com/users/teckays/followers","following_url":"https://api.github.com/users/teckays/following{/other_user}","gists_url":"https://api.github.com/users/teckays/gists{/gist_id}","starred_url":"https://api.github.com/users/teckays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teckays/subscriptions","organizations_url":"https://api.github.com/users/teckays/orgs","repos_url":"https://api.github.com/users/teckays/repos","events_url":"https://api.github.com/users/teckays/events{/privacy}","received_events_url":"https://api.github.com/users/teckays/received_events","type":"User","site_admin":false},"created_at":"2016-02-28T19:20:12Z","updated_at":"2016-02-28T19:20:12Z","body":"@whytheday \r\n> Also, seems kind of strange you would create the table outside of the migration script ...\r\n\r\nI'm not creating it outside, I just run different migrations, let's say I have my base schema file, then create another migration file with schema updates, change a field type for example, and the migration fails because the table already exists, I'm not creating the tables manually, it's just different migrations files applied and the tables don't drop when upgrading the schema.\r\n\r\n> If you are trying to test the migration you should use \"knex migrate:rollback\"\r\n\r\ndoesn't `rollback` resets the previous migration? "}}