feat(sync): synchronize customer addresses

Mirror the addresses embedded in GET /customer/🆔 per customer, delete
the ones missing from Hiboutik, then upsert each of them (failures logged
and skipped). CustomerAddress gains its own recipient (firstName,
lastName, company, phone) plus state and other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MastersGame
2026-11-07 10:37:00 +01:00
parent c5f65dcb62
commit 9e6e5162ad
7 changed files with 229 additions and 7 deletions

View File

@@ -146,16 +146,23 @@ model Customer {
@@map("customers")
}
/// Address of a customer, mirrored from Hiboutik (sync not implemented yet).
/// Address of a customer, mirrored from Hiboutik. Its recipient (name, company, phone) can differ from the customer.
model CustomerAddress {
id String @id @default(uuid())
updatedAt DateTime @updatedAt
address String
city String
company String?
country String
firstName String
hiboutikId Int @unique
isDefault Boolean @default(false)
lastName String
/// Free complement (building, floor, door code...)
other String?
phone String?
state String?
zipCode String
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)