fix(db): seed ON CONFLICT target uses clients.id instead of non-unique clients.email

Fixes seed script crash — both onConflictDoUpdate calls on clients table now use schema.clients.id (PK) as conflict target instead of non-unique schema.clients.email. Email added to set clause for both call sites.

Resolves GRO-298. Unblocks GRO-290, GRO-295, GRO-297.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit was merged in pull request #182.
This commit is contained in:
groombook-engineer[bot]
2026-03-30 14:44:38 +00:00
committed by GitHub
parent b385b32120
commit 40143c4efa
+3 -3
View File
@@ -516,8 +516,8 @@ async function seed() {
await db.insert(schema.clients)
.values(client)
.onConflictDoUpdate({
target: schema.clients.email,
set: { name: client.name, phone: client.phone, address: client.address, notes: client.notes, emailOptOut: client.emailOptOut },
target: schema.clients.id,
set: { name: client.name, email: client.email, phone: client.phone, address: client.address, notes: client.notes, emailOptOut: client.emailOptOut },
});
}
@@ -570,7 +570,7 @@ async function seed() {
for (const uc of uatClients) {
await db.insert(schema.clients)
.values({ id: uc.id, name: uc.name, email: uc.email, phone: uc.phone, address: uc.address })
.onConflictDoUpdate({ target: schema.clients.email, set: { name: uc.name, phone: uc.phone, address: uc.address } });
.onConflictDoUpdate({ target: schema.clients.id, set: { name: uc.name, email: uc.email, phone: uc.phone, address: uc.address } });
await db.insert(schema.pets)
.values({ id: uc.petId, clientId: uc.id, name: uc.petName, species: "Dog", breed: uc.petBreed, weightKg: "25.00", dateOfBirth: new Date("2021-03-15T00:00:00Z") })
.onConflictDoUpdate({ target: schema.pets.id, set: { clientId: uc.id, name: uc.petName, species: "Dog", breed: uc.petBreed, weightKg: "25.00", dateOfBirth: new Date("2021-03-15T00:00:00Z") } });