Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 56b20a3457 | |||
| 1aab3bf4e8 |
+45
-18
@@ -609,8 +609,45 @@ async function seedUatStaffAccounts(db: ReturnType<typeof drizzle>) {
|
|||||||
.from(schema.pets)
|
.from(schema.pets)
|
||||||
.where(eq(schema.pets.id, pet.id))
|
.where(eq(schema.pets.id, pet.id))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
console.log(`✓ UAT Pet '${existing.name}' already exists — skipping`);
|
// Upsert so extended fields are always populated on re-runs
|
||||||
|
await db.insert(schema.pets)
|
||||||
|
.values({
|
||||||
|
id: pet.id,
|
||||||
|
clientId: uatCustomerClientId,
|
||||||
|
name: pet.name,
|
||||||
|
species: pet.species,
|
||||||
|
breed: pet.breed,
|
||||||
|
weightKg: pet.weight,
|
||||||
|
dateOfBirth: new Date(`${pet.dob}T00:00:00Z`),
|
||||||
|
image: pet.image,
|
||||||
|
temperamentScore: randInt(1, 5),
|
||||||
|
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
||||||
|
medicalAlerts: [],
|
||||||
|
preferredCuts: pickN(preferredCutPool, randInt(1, 2)),
|
||||||
|
coatType: pick(coatTypePool),
|
||||||
|
petSizeCategory: pick(petSizeCategoryPool),
|
||||||
|
})
|
||||||
|
.onConflictDoUpdate({
|
||||||
|
target: schema.pets.id,
|
||||||
|
set: {
|
||||||
|
clientId: uatCustomerClientId,
|
||||||
|
name: pet.name,
|
||||||
|
species: pet.species,
|
||||||
|
breed: pet.breed,
|
||||||
|
weightKg: pet.weight,
|
||||||
|
dateOfBirth: new Date(`${pet.dob}T00:00:00Z`),
|
||||||
|
image: pet.image,
|
||||||
|
temperamentScore: randInt(1, 5),
|
||||||
|
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
||||||
|
medicalAlerts: [],
|
||||||
|
preferredCuts: pickN(preferredCutPool, randInt(1, 2)),
|
||||||
|
coatType: pick(coatTypePool),
|
||||||
|
petSizeCategory: pick(petSizeCategoryPool),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(`✓ Upserted UAT pet '${pet.name}' with extended fields`);
|
||||||
} else {
|
} else {
|
||||||
await db.insert(schema.pets).values({
|
await db.insert(schema.pets).values({
|
||||||
id: pet.id,
|
id: pet.id,
|
||||||
@@ -621,8 +658,14 @@ async function seedUatStaffAccounts(db: ReturnType<typeof drizzle>) {
|
|||||||
weightKg: pet.weight,
|
weightKg: pet.weight,
|
||||||
dateOfBirth: new Date(`${pet.dob}T00:00:00Z`),
|
dateOfBirth: new Date(`${pet.dob}T00:00:00Z`),
|
||||||
image: pet.image,
|
image: pet.image,
|
||||||
|
temperamentScore: randInt(1, 5),
|
||||||
|
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
||||||
|
medicalAlerts: [],
|
||||||
|
preferredCuts: pickN(preferredCutPool, randInt(1, 2)),
|
||||||
|
coatType: pick(coatTypePool),
|
||||||
|
petSizeCategory: pick(petSizeCategoryPool),
|
||||||
});
|
});
|
||||||
console.log(`✓ Created UAT pet '${pet.name}'`);
|
console.log(`✓ Created UAT pet '${pet.name}' with extended fields`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -966,14 +1009,6 @@ async function seed() {
|
|||||||
temperamentScore: randInt(1, 5),
|
temperamentScore: randInt(1, 5),
|
||||||
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
||||||
medicalAlerts: (() => {
|
medicalAlerts: (() => {
|
||||||
// Deterministic alerts for UAT AC pets
|
|
||||||
if (uc.petName === "TestCooper") {
|
|
||||||
return pickN(medicalAlertPool.filter((a) => a.type === "behavioral"), 1).map((a) => ({ ...a, id: uuid() }));
|
|
||||||
}
|
|
||||||
if (uc.petName === "TestRocky") {
|
|
||||||
return pickN(medicalAlertPool.filter((a) => a.type === "skin"), 1).map((a) => ({ ...a, id: uuid() }));
|
|
||||||
}
|
|
||||||
// Other UAT pets: random
|
|
||||||
if (rand() < 0.3) {
|
if (rand() < 0.3) {
|
||||||
const count = rand() < 0.7 ? 1 : 2;
|
const count = rand() < 0.7 ? 1 : 2;
|
||||||
return pickN(medicalAlertPool, count).map((a) => ({ ...a, id: uuid() }));
|
return pickN(medicalAlertPool, count).map((a) => ({ ...a, id: uuid() }));
|
||||||
@@ -1101,14 +1136,6 @@ async function seed() {
|
|||||||
temperamentScore: randInt(1, 5),
|
temperamentScore: randInt(1, 5),
|
||||||
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
||||||
medicalAlerts: (() => {
|
medicalAlerts: (() => {
|
||||||
// Deterministic alerts for UAT AC pets
|
|
||||||
if (uc.petName === "TestCooper") {
|
|
||||||
return pickN(medicalAlertPool.filter((a) => a.type === "behavioral"), 1).map((a) => ({ ...a, id: uuid() }));
|
|
||||||
}
|
|
||||||
if (uc.petName === "TestRocky") {
|
|
||||||
return pickN(medicalAlertPool.filter((a) => a.type === "skin"), 1).map((a) => ({ ...a, id: uuid() }));
|
|
||||||
}
|
|
||||||
// Other UAT pets: random
|
|
||||||
if (rand() < 0.3) {
|
if (rand() < 0.3) {
|
||||||
const count = rand() < 0.7 ? 1 : 2;
|
const count = rand() < 0.7 ? 1 : 2;
|
||||||
return pickN(medicalAlertPool, count).map((a) => ({ ...a, id: uuid() }));
|
return pickN(medicalAlertPool, count).map((a) => ({ ...a, id: uuid() }));
|
||||||
|
|||||||
Reference in New Issue
Block a user