1

In sequelize.js I try to use migration to create a table, here is how I define an id column in my code:

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable(tableName, {
      id: {
        type: Sequelize.INTEGER,
        autoIncrement: true,
        primaryKey: true,
        defaultValue: 100,

I want the id column auto increase from 100

However, when I try to run this migration, the terminal tell me:

ERROR: Invalid default value for 'id'

I find out if I commentted the autoIncrement attribute, it could work. But maybe it cannot auto increase.

How can I let the id column auto increase from a default value?

hh54188
  • 14,887
  • 32
  • 113
  • 184
  • https://stackoverflow.com/questions/33775165/auto-increment-id-with-sequelize-in-mysql You can check this! – xetryDcoder Sep 07 '20 at 14:17
  • 1
    I would suggest to burn the first one hundred by inserting generated one hundred registers and then delete them all, lmao. The thing is that auto increment is a property of the Primary Key inside the column, try using a raw query inside the migration -> ALTER TABLE tbl AUTO_INCREMENT = 100; see if that's work – Fernando Zamperin Sep 07 '20 at 23:13

0 Answers0