I am using MySQL db with Sails.js (Waterline).
How do I set the initial value for an "id" column in a MySQL table that start from 1000?
attributes: {
id: {
type: 'integer'
// start from 1000
}
}
I am using MySQL db with Sails.js (Waterline).
How do I set the initial value for an "id" column in a MySQL table that start from 1000?
attributes: {
id: {
type: 'integer'
// start from 1000
}
}
So you want to
ALTER TABLE model AUTO_INCREMENT = 1000
In waterline you can run this query with the .query() method. However since this query will rebuild your entire table, it is not recommended to be run while bootstrapping your app. Depending on the size of your table it could slow down startup of your app.
Best match would be to somehow hook into the table create event and run above query once or even better: use migrations https://github.com/BlueHotDog/sails-migrations
Further reading: