{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/1399","repository_url":"https://api.github.com/repos/tgriesser/knex","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/1399/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1399/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/1399/events","html_url":"https://github.com/tgriesser/knex/pull/1399","id":154355172,"number":1399,"title":"Add option for an array of ignorable migration errors","user":{"login":"benf86","id":4596061,"avatar_url":"https://avatars.githubusercontent.com/u/4596061?v=3","gravatar_id":"","url":"https://api.github.com/users/benf86","html_url":"https://github.com/benf86","followers_url":"https://api.github.com/users/benf86/followers","following_url":"https://api.github.com/users/benf86/following{/other_user}","gists_url":"https://api.github.com/users/benf86/gists{/gist_id}","starred_url":"https://api.github.com/users/benf86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benf86/subscriptions","organizations_url":"https://api.github.com/users/benf86/orgs","repos_url":"https://api.github.com/users/benf86/repos","events_url":"https://api.github.com/users/benf86/events{/privacy}","received_events_url":"https://api.github.com/users/benf86/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tgriesser/knex/labels/wontfix","name":"wontfix","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-11T22:14:19Z","updated_at":"2016-05-12T00:16:07Z","closed_at":"2016-05-11T23:57:48Z","pull_request":{"url":"https://api.github.com/repos/tgriesser/knex/pulls/1399","html_url":"https://github.com/tgriesser/knex/pull/1399","diff_url":"https://github.com/tgriesser/knex/pull/1399.diff","patch_url":"https://github.com/tgriesser/knex/pull/1399.patch"},"body":"The user can provide an array of error codes, which should be ignored when migrating, in the migrations.ignoreErrors part of the knex config, e.g.:\r\n\r\n`\"migrations\": {\r\n    \"ignoreErrors\": [\r\n      \"ER_DUP_FIELDNAME\",\r\n      \"ER_CANT_DROP_FIELD_OR_KEY\"\r\n    ]\r\n  }`\r\n\r\nIt was originally inspired by the idea that a migration which fails to e.g. delete a column, which had already been deleted (for whatever reason) isn't necessarily something that should stop the whole migration process from continuing.\r\n\r\nThe error gets added to the log array returned by the migration function, so the user can still decide how to handle it.\r\n\r\nFailed migration errors now also include the failed migration file name for easier locating."},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/218626933","html_url":"https://github.com/tgriesser/knex/pull/1399#issuecomment-218626933","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/1399","id":218626933,"user":{"login":"benf86","id":4596061,"avatar_url":"https://avatars.githubusercontent.com/u/4596061?v=3","gravatar_id":"","url":"https://api.github.com/users/benf86","html_url":"https://github.com/benf86","followers_url":"https://api.github.com/users/benf86/followers","following_url":"https://api.github.com/users/benf86/following{/other_user}","gists_url":"https://api.github.com/users/benf86/gists{/gist_id}","starred_url":"https://api.github.com/users/benf86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benf86/subscriptions","organizations_url":"https://api.github.com/users/benf86/orgs","repos_url":"https://api.github.com/users/benf86/repos","events_url":"https://api.github.com/users/benf86/events{/privacy}","received_events_url":"https://api.github.com/users/benf86/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T00:16:07Z","updated_at":"2016-05-12T00:16:07Z","body":"> Or you can manually catch the errors in each migration where you're permitting it to fail.\r\n\r\nWhy didn't I even think of that -_-\r\n\r\nWhile the migration counting even though it wouldn't execute was useful to my use case, you're obviously right that manually catching migrations errors is an option.\r\n\r\nThanks for the explanation and keep up the great work with knex!"}}