/** * Seeds the bookable-objects catalog with the distinct items visible across * the old bot's booking history, so the list isn't empty on first use. * Idempotent — skips names that already exist. */ import { db } from "../src/lib/db/client"; import { bookableObjects } from "../src/lib/db/schema"; const SEED_NAMES = [ "Баня", "Чан", "Афрейм", "Шале", "Банный комплекс", "Дом с ванной", "Дом с баней", "Банкетный зал", "Беседка открытая", "Вся база без кафе", ]; async function main() { const existing = await db.query.bookableObjects.findMany({ columns: { name: true } }); const existingNames = new Set(existing.map((o) => o.name)); const toInsert = SEED_NAMES.filter((n) => !existingNames.has(n)); if (toInsert.length === 0) { console.log("Bookable objects already seeded — skipping."); return; } await db.insert(bookableObjects).values(toInsert.map((name, i) => ({ name, sortOrder: i }))); console.log(`Seeded ${toInsert.length} bookable object(s): ${toInsert.join(", ")}`); } main() .then(() => process.exit(0)) .catch((err) => { console.error("Object seeding failed:", err); process.exit(1); });