diff --git a/src/db/seed-global-items.ts b/src/db/seed-global-items.ts index 9c11d9a..e2a55ea 100644 --- a/src/db/seed-global-items.ts +++ b/src/db/seed-global-items.ts @@ -70,14 +70,16 @@ const SEED_TAGS = [ /** * Seed curated tags for outdoor/adventure gear. - * Idempotent: skips if any tags already exist. + * Idempotent: inserts only tags that don't already exist. */ export async function seedTags(db: Db = prodDb) { - const existing = await db.select().from(tags).limit(1); - if (existing.length > 0) return; + const existing = await db.select().from(tags); + const existingNames = new Set(existing.map((t) => t.name)); for (const name of SEED_TAGS) { - await db.insert(tags).values({ name }); + if (!existingNames.has(name)) { + await db.insert(tags).values({ name }); + } } }