Search code examples
auto-incrementresetknex.jsnode-sqlite3

Set AUTO_INCREMENT value in sqlite3 using knex.js


I'm using the knex v0.19.1 with Node.js. I've searched through entire Docs of knex.js but didn't find a way to reset AUTO_INCREMENT to specific value knex way. Is there any workaround to achieve this? or i need to execute the pure query as alter table TAB_NAME set AUTO_INCREMENT = 45 by sqlite3 driver itself?


Solution

  • Yes. You need to use raw query to do that, but you can do it for example with knex.schema.raw(). No need to use sqlite3 driver directly.