{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/46","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/46/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/46/events","html_url":"https://github.com/tgriesser/knex/issues/46","id":18458878,"number":46,"title":"Modifying columns","user":{"login":"ErisDS","id":101513,"avatar_url":"https://avatars.githubusercontent.com/u/101513?v=3","gravatar_id":"","url":"https://api.github.com/users/ErisDS","html_url":"https://github.com/ErisDS","followers_url":"https://api.github.com/users/ErisDS/followers","following_url":"https://api.github.com/users/ErisDS/following{/other_user}","gists_url":"https://api.github.com/users/ErisDS/gists{/gist_id}","starred_url":"https://api.github.com/users/ErisDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ErisDS/subscriptions","organizations_url":"https://api.github.com/users/ErisDS/orgs","repos_url":"https://api.github.com/users/ErisDS/repos","events_url":"https://api.github.com/users/ErisDS/events{/privacy}","received_events_url":"https://api.github.com/users/ErisDS/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tgriesser/knex/labels/feature","name":"feature","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2013-08-23T08:20:39Z","updated_at":"2015-02-01T00:38:00Z","closed_at":null,"body":"I think it is a reasonable expectation that it would be possible to:\r\n\r\n- rename a column\r\n- change the data type\r\n- add or drop the null constraint\r\n- change the default \r\n\r\nAnd probably other things that I have not thought of. \r\n\r\nI would imagine the syntax for doing this would be something like\r\n\r\n```\r\n knex.Schema.table('table_name', function (t) {\r\n        t.string('my_column').renameTo('something_else');\r\n        t.string('my_column').changeTo('text');\r\n        t.string('my_column').nullable() < adds nullable if not already present\r\n        t.string('my_column').notNullable() < removes nullable if present\r\n        t.string('my_column').defaultTo('whatever') < adds or updates the default\r\n  });\r\n```\r\n\r\nMaybe there needs to be something extra in the chain, possibly at the `knex.Schema.table` level to indicate that this is a modify statement not an add.\r\n\r\nI realise that this is tricky to implement across various databases, especially in SQLite where you have to create a whole new table, but in a system which requires migrations, without these tools it is going to be necessary to use knex.raw and write all the migrations for each DB supported, which sort of defeats the point of having a nice ORM especially one which is about to support migrations.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/72344915","html_url":"https://github.com/tgriesser/knex/issues/46#issuecomment-72344915","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/46","id":72344915,"user":{"login":"dkushner","id":1289314,"avatar_url":"https://avatars.githubusercontent.com/u/1289314?v=3","gravatar_id":"","url":"https://api.github.com/users/dkushner","html_url":"https://github.com/dkushner","followers_url":"https://api.github.com/users/dkushner/followers","following_url":"https://api.github.com/users/dkushner/following{/other_user}","gists_url":"https://api.github.com/users/dkushner/gists{/gist_id}","starred_url":"https://api.github.com/users/dkushner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkushner/subscriptions","organizations_url":"https://api.github.com/users/dkushner/orgs","repos_url":"https://api.github.com/users/dkushner/repos","events_url":"https://api.github.com/users/dkushner/events{/privacy}","received_events_url":"https://api.github.com/users/dkushner/received_events","type":"User","site_admin":false},"created_at":"2015-02-01T00:38:00Z","updated_at":"2015-02-01T00:38:00Z","body":"@tgriesser, @bendrucker: Has there been any update on this functionality? Writing raw queries in every migration I have that modifies a column (virtually all of them), is getting a bit frustrating."}}