chore: promote dev → uat (GRO-1743 seed data) #70
@@ -36,6 +36,18 @@ const DEMO_PET = {
|
|||||||
weightKg: "30.00",
|
weightKg: "30.00",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const UAT_CLIENT = {
|
||||||
|
name: "UAT Customer",
|
||||||
|
email: "uat-customer@groombook.dev",
|
||||||
|
phone: "555-0100",
|
||||||
|
status: "active" as const,
|
||||||
|
};
|
||||||
|
|
||||||
|
const UAT_PETS = [
|
||||||
|
{ name: "Bella", species: "Dog", breed: "Poodle", coatType: "curly" as const },
|
||||||
|
{ name: "Max", species: "Dog", breed: "Labrador Retriever", coatType: "short" as const },
|
||||||
|
];
|
||||||
|
|
||||||
const DEMO_SERVICES = [
|
const DEMO_SERVICES = [
|
||||||
{ id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 },
|
{ id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 },
|
||||||
{ id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 },
|
{ id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 },
|
||||||
@@ -128,6 +140,49 @@ adminSeedRouter.post("/seed", async (c) => {
|
|||||||
results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`);
|
results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Client: UAT Customer ──────────────────────────────────────────────────
|
||||||
|
const [existingUatClient] = await db
|
||||||
|
.select()
|
||||||
|
.from(clients)
|
||||||
|
.where(eq(clients.email, UAT_CLIENT.email));
|
||||||
|
|
||||||
|
let uatClientId: string;
|
||||||
|
if (existingUatClient) {
|
||||||
|
uatClientId = existingUatClient.id;
|
||||||
|
results.push(`Client '${UAT_CLIENT.name}' already exists (id: ${uatClientId})`);
|
||||||
|
} else {
|
||||||
|
const [created] = await db.insert(clients).values(UAT_CLIENT).returning();
|
||||||
|
uatClientId = created!.id;
|
||||||
|
results.push(`Created client '${UAT_CLIENT.name}' (id: ${uatClientId})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Pets: UAT Customer Pets ───────────────────────────────────────────────
|
||||||
|
const existingUatPets = await db
|
||||||
|
.select()
|
||||||
|
.from(pets)
|
||||||
|
.where(eq(pets.clientId, uatClientId));
|
||||||
|
|
||||||
|
for (const uatPet of UAT_PETS) {
|
||||||
|
const existingPet = existingUatPets.find(
|
||||||
|
(p) => p.name === uatPet.name && p.species === uatPet.species
|
||||||
|
);
|
||||||
|
if (existingPet) {
|
||||||
|
results.push(`Pet '${uatPet.name}' already exists for UAT Customer (id: ${existingPet.id})`);
|
||||||
|
} else {
|
||||||
|
const [created] = await db
|
||||||
|
.insert(pets)
|
||||||
|
.values({
|
||||||
|
clientId: uatClientId,
|
||||||
|
name: uatPet.name,
|
||||||
|
species: uatPet.species,
|
||||||
|
breed: uatPet.breed,
|
||||||
|
coatType: uatPet.coatType,
|
||||||
|
})
|
||||||
|
.returning();
|
||||||
|
results.push(`Created pet '${uatPet.name}' for UAT Customer (id: ${created!.id})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
message: "Seed complete",
|
message: "Seed complete",
|
||||||
details: results,
|
details: results,
|
||||||
|
|||||||
Reference in New Issue
Block a user