Reputation: 51
I am having an issue with typeorm + postgres on my production server, it keep throwing this error in the console but the app is still running (Not breasking)
Nest] 41 - 11/03/2022, 9:44:20 AM ERROR [ExceptionsHandler] duplicate key value violates unique constraint "UQ_167efd0746b6a9808b96f2e0d66" QueryFailedError: duplicate key value violates unique constraint "UQ_167efd0746b6a9808b96f2e0d66" at QueryFailedError.TypeORMError [as constructor] (/app/src/error/TypeORMError.ts:7:9) at new QueryFailedError (/app/src/error/QueryFailedError.ts:9:9) at PostgresQueryRunner. (/app/src/driver/postgres/PostgresQueryRunner.ts:247:19) at step (/app/node_modules/typeorm/node_modules/tslib/tslib.js:144:27) at Object.throw (/app/node_modules/typeorm/node_modules/tslib/tslib.js:125:57) at rejected (/app/node_modules/typeorm/node_modules/tslib/tslib.js:116:69) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5)
Upvotes: 1
Views: 1791
Reputation: 54
It means your are inserting some data that already exist in the database. If you wanna insert same data into database, Define your columns in your entity like this:
@Column({ unique: false })
firstName: string;
Upvotes: 1