{"action":"opened","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/1091","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/1091/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1091/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/1091/events","html_url":"https://github.com/tgriesser/knex/issues/1091","id":121477878,"number":1091,"title":"'dropColumn' within 'hasColumn' does not work","user":{"login":"techniq","id":177476,"avatar_url":"https://avatars.githubusercontent.com/u/177476?v=3","gravatar_id":"","url":"https://api.github.com/users/techniq","html_url":"https://github.com/techniq","followers_url":"https://api.github.com/users/techniq/followers","following_url":"https://api.github.com/users/techniq/following{/other_user}","gists_url":"https://api.github.com/users/techniq/gists{/gist_id}","starred_url":"https://api.github.com/users/techniq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techniq/subscriptions","organizations_url":"https://api.github.com/users/techniq/orgs","repos_url":"https://api.github.com/users/techniq/repos","events_url":"https://api.github.com/users/techniq/events{/privacy}","received_events_url":"https://api.github.com/users/techniq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-10T12:59:10Z","updated_at":"2015-12-10T12:59:10Z","closed_at":null,"body":"I was attempting to make my rollback's more resilient when a column does not exist when being dropped (happens on a failed migration on occasion), and since there is not a `dropColumnIfNotExists`, I attempted to use `knex.schema.hasColumn` and then perform the `table.dropColumn` if exists.  Oddly, `table.dropColumn` is not ran if performed within the `hasColumn`, but works just fine outside of the check.\r\n\r\n```js\r\nexports.down = function(knex, Promise) {\r\n  return knex.schema.table('address', function (table) {\r\n\r\n    // Doesn't work\r\n    knex.schema.hasColumn('address', 'geocode_source').then(function (exists) {\r\n      if (exists) {\r\n        table.dropColumn('geocode_source');\r\n      }\r\n    });\r\n\r\n    knex.schema.hasColumn('address', 'geocode_quality').then(function (exists) {\r\n      if (exists) {\r\n        table.dropColumn('geocode_quality');\r\n      }\r\n    });\r\n\r\n    // Works\r\n    //table.dropColumn('geocode_source');\r\n    //table.dropColumn('geocode_quality');\r\n});\r\n```"}}