0

I am using pg_dump/pg_restore to migrate data from one database to another, but some of tables have autoIncrements defined on the ids.

The autoIncrement is defined with:

  .createTable('MyTable', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER,
    },

When I try to create a new entry to the table using sequelize I get the error "SequelizeUniqueConstraintError: Validation error" as it is trying to set the id using autoIncrement starting at 0, instead of the next unused number. How can I fix this?

Michael
  • 365
  • 4
  • 15

0 Answers0