Hello guys,
I have a model with an auto generated id as PK. However, I want to force the id to start in 3 instead of 1 (as usual).
There is an easy way so I can do this? What do I need to add to my model?
Thanks! :)
To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:
mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;
https://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
This can easily be done with a raw query, so this is not functionality that belongs in sequelize core
So what's the use of sequelize, if not, to abstract the database layer? I came here from google looking for the same functionality only to find out that the expected path is to use raw SQL anyways, go figure.
This is a very useful feature that should be in the sequelize configurations & models too. Because it's a common practice by many applications when going into production they start their ids of all the tables from 1000, 100000, or maybe a random number, so that the actual count of data can not be determined. Otherwise, just to do this we have to write a separate script that needs to be manually executed on the database server.
Most helpful comment
So what's the use of sequelize, if not, to abstract the database layer? I came here from google looking for the same functionality only to find out that the expected path is to use raw SQL anyways, go figure.