"Creation Failed: ID Must Be Unique" Error

Hi @kristina :wave: Thank you for your feedback.

What database dialect do you use? (PostgreSQL, MySQL, MongoDB, MSSQL)

There may be a problem with the id field definition. Could you please share your code model (only the relevant part, e.g: the id field definition, and configuration at the end of the file)? Could you also share the CREATE TABLE definition, assuming you use a SQL dialect? (also, just keep the relevant part, to avoid sharing publically sensitive information).

If you use SQL dialect, is your field a serial ID (also known as auto-increment) or an UUID? Assuming you use UUID and an SQL dialect, you could try to define your field as follow:

id: {
  type: DataTypes.UUID,
  primaryKey: true,
  defaultValue: Sequelize.literal('gen_random_uuid()')
},
1 Like