Merge branch 'main' into fix/gro-689-oidc-hostname-validation
This commit is contained in:
@@ -462,6 +462,37 @@ async function seedKnownUsers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Staff: UAT Groomer Personas (SEED_UAT_GROOMER_EMAILS + SEED_UAT_GROOMER_NAMES) ──
|
||||||
|
const groomerEmails = process.env.SEED_UAT_GROOMER_EMAILS?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
|
||||||
|
const groomerNames = process.env.SEED_UAT_GROOMER_NAMES?.split(",").map((n) => n.trim()).filter(Boolean) ?? [];
|
||||||
|
const groomerCount = Math.min(groomerEmails.length, groomerNames.length);
|
||||||
|
for (let i = 0; i < groomerCount; i++) {
|
||||||
|
const email = groomerEmails[i]!;
|
||||||
|
const name = groomerNames[i]!;
|
||||||
|
// Use deterministic IDs in the 00000000-0000-0000-0000-000000000005+ range
|
||||||
|
const staffId = `00000000-0000-0000-0000-${String(5 + i).padStart(12, "0")}`;
|
||||||
|
const [existingGroomer] = await db
|
||||||
|
.select()
|
||||||
|
.from(schema.staff)
|
||||||
|
.where(eq(schema.staff.email, email))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (existingGroomer) {
|
||||||
|
console.log(`✓ Staff groomer '${existingGroomer.name}' already exists — skipping`);
|
||||||
|
} else {
|
||||||
|
await db.insert(schema.staff).values({
|
||||||
|
id: staffId,
|
||||||
|
name,
|
||||||
|
email,
|
||||||
|
oidcSub: email,
|
||||||
|
role: "groomer",
|
||||||
|
isSuperUser: false,
|
||||||
|
active: true,
|
||||||
|
});
|
||||||
|
console.log(`✓ Created staff groomer '${name}' (${email})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Services: idempotent upsert using name as unique key ─────────────────────
|
// ── Services: idempotent upsert using name as unique key ─────────────────────
|
||||||
// UNIQUE constraint on services.name (migration 0020) must exist first.
|
// UNIQUE constraint on services.name (migration 0020) must exist first.
|
||||||
// Uses b0000001-... IDs to match main seed servicesDef for same-named services.
|
// Uses b0000001-... IDs to match main seed servicesDef for same-named services.
|
||||||
@@ -629,6 +660,31 @@ async function seed() {
|
|||||||
console.log(`✓ Upserted admin staff '${adminName}' (${adminEmail})`);
|
console.log(`✓ Upserted admin staff '${adminName}' (${adminEmail})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── UAT Groomer Personas (SEED_UAT_GROOMER_EMAILS + SEED_UAT_GROOMER_NAMES) ──
|
||||||
|
const groomerEmails = process.env.SEED_UAT_GROOMER_EMAILS?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
|
||||||
|
const groomerNames = process.env.SEED_UAT_GROOMER_NAMES?.split(",").map((n) => n.trim()).filter(Boolean) ?? [];
|
||||||
|
const groomerCount = Math.min(groomerEmails.length, groomerNames.length);
|
||||||
|
for (let i = 0; i < groomerCount; i++) {
|
||||||
|
const email = groomerEmails[i]!;
|
||||||
|
const name = groomerNames[i]!;
|
||||||
|
const staffId = `00000000-0000-0000-0000-${String(5 + i).padStart(12, "0")}`;
|
||||||
|
await db.insert(schema.staff)
|
||||||
|
.values({
|
||||||
|
id: staffId,
|
||||||
|
name,
|
||||||
|
email,
|
||||||
|
oidcSub: email,
|
||||||
|
role: "groomer",
|
||||||
|
isSuperUser: false,
|
||||||
|
active: true,
|
||||||
|
})
|
||||||
|
.onConflictDoUpdate({
|
||||||
|
target: schema.staff.email,
|
||||||
|
set: { id: staffId, name, role: "groomer", isSuperUser: false, active: true },
|
||||||
|
});
|
||||||
|
console.log(`✓ Upserted groomer '${name}' (${email})`);
|
||||||
|
}
|
||||||
|
|
||||||
// ── Services ──
|
// ── Services ──
|
||||||
// Upsert services using name as unique key. With deterministic IDs in
|
// Upsert services using name as unique key. With deterministic IDs in
|
||||||
// servicesDef and TRUNCATE clearing downstream tables first, this is
|
// servicesDef and TRUNCATE clearing downstream tables first, this is
|
||||||
|
|||||||
Reference in New Issue
Block a user