Knex primary key auto increment

A bit late to the party but I was having this issue with the same use case. However my solution was I didnt have all the correct permissions granted to my sequences, only my tables when i ceated the DB.

So something along the lines of "GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO PUBLIC"


My problem was that the value for id was an empty string and not undefined or null, so that was braking the constraint for integer as data type.

Hope it helps!


In js: table.increments()

Output sql: id int unsigned not null auto_increment primary key

check this out for more information