Lacerda
Lacerda
DTDrizzle Team
Created by Lacerda on 10/1/2023 in #help
error: there is no unique or exclusion constraint matching the ON CONFLICT specification
Seems that the UNIQUE don't fix the problem. Table:
export const product = pgTable("product", {
id: uuid("id").primaryKey().notNull(),
marketId: text("market_id").notNull().unique().references(() => market.id),
url: text("url").unique(),
name: text("name").notNull().unique(),
brandname: text("brandname").unique(),
quantity: text("quantity").notNull().unique(),
originalprice: real("originalprice"),
realprice: real("realprice"),
priceperquantity: real("priceperquantity"),
unit: text("unit").notNull(),
urlimage: text("urlimage").notNull(),
});
export const product = pgTable("product", {
id: uuid("id").primaryKey().notNull(),
marketId: text("market_id").notNull().unique().references(() => market.id),
url: text("url").unique(),
name: text("name").notNull().unique(),
brandname: text("brandname").unique(),
quantity: text("quantity").notNull().unique(),
originalprice: real("originalprice"),
realprice: real("realprice"),
priceperquantity: real("priceperquantity"),
unit: text("unit").notNull(),
urlimage: text("urlimage").notNull(),
});
The error:
error: there is no unique or exclusion constraint matching the ON CONFLICT specification
at index.js:45:11
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async session.ts:64:19
at async insertOrUpdateProduct (database.ts:80:51) {
length: 148,
severity: 'ERROR',
code: '42P10',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'plancat.c',
line: '863',
routine: 'infer_arbiter_indexes'
}
error: there is no unique or exclusion constraint matching the ON CONFLICT specification
at index.js:45:11
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async session.ts:64:19
at async insertOrUpdateProduct (database.ts:80:51) {
length: 148,
severity: 'ERROR',
code: '42P10',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'plancat.c',
line: '863',
routine: 'infer_arbiter_indexes'
}
6 replies
DTDrizzle Team
Created by Lacerda on 10/1/2023 in #help
error: there is no unique or exclusion constraint matching the ON CONFLICT specification
UNIQUE or UNIQUE INDEX? What is the best option on this case?
6 replies