Reputation: 7081
I am trying to change the Datatype of my primarykey to String in sequelize and am getting the following error while trying to create using upsert.
error: SequelizeDatabaseError: null value in column "id" violates not-null constraint
here is the code:
id: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: true,
autoIncrement: false,
field: "id"
}
How do I make this work? thanks in advance.
Upvotes: 5
Views: 8762
Reputation: 121889
For the documentation:
Technically, a primary key constraint is simply a combination of a unique constraint and a not-null constraint.
You cannot create nullable primary key.
...
allowNull: false,
...
Upvotes: 4