From 1463dde802565efad025cccecc5f951eba295d49 Mon Sep 17 00:00:00 2001 From: ajnart <49837342+ajnart@users.noreply.github.com> Date: Thu, 18 Jun 2026 09:29:47 +0200 Subject: [PATCH] fix(db): replace onConflictDoNothing with dialect-neutral pre-filter onConflictDoNothing is only defined on Drizzle's SQLite and Postgres insert builders. MySQL insert builder lacks this method, causing a TypeError at startup for all MySQL/MariaDB installations. Replaced with a dialect-neutral pre-filter that queries existing widget IDs and only inserts rows that don't already exist. This matches the count-first/skip pattern used by every other seed function in the file and keeps a single code path across all dialects. Closes #5967 --- packages/db/migrations/seed.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/db/migrations/seed.ts b/packages/db/migrations/seed.ts index 56d765d4a..6ec906cec 100644 --- a/packages/db/migrations/seed.ts +++ b/packages/db/migrations/seed.ts @@ -647,9 +647,13 @@ const seedDemoUserAsync = async (db: Database) => { const seedDefaultCustomWidgetsAsync = async (db: Database) => { const seedIds = CUSTOM_WIDGET_SEEDS.map((s) => s.id); - const beforeCount = await db.$count(customWidgetDefinitions, inArray(customWidgetDefinitions.id, seedIds)); + const existing = await db.query.customWidgetDefinitions.findMany({ + columns: { id: true }, + where: inArray(customWidgetDefinitions.id, seedIds), + }); + const existingIds = new Set(existing.map((row) => row.id)); - const seedValues = CUSTOM_WIDGET_SEEDS.map((seed) => { + const seedValues = CUSTOM_WIDGET_SEEDS.filter((seed) => !existingIds.has(seed.id)).map((seed) => { const parsed = customWidgetImportSchema.parse(seed.data); return { id: seed.id, @@ -668,22 +672,14 @@ const seedDefaultCustomWidgetsAsync = async (db: Database) => { }; }); - if (seedValues.length === 0) return; - - await db - .insert(customWidgetDefinitions) - .values(seedValues) - .onConflictDoNothing({ target: customWidgetDefinitions.id }); - - const afterCount = await db.$count(customWidgetDefinitions, inArray(customWidgetDefinitions.id, seedIds)); - const createdCount = afterCount - beforeCount; - - if (createdCount === 0) { + if (seedValues.length === 0) { console.log("Skipping seeding of default custom widgets as they already exist"); return; } - console.log(`Created ${createdCount} default custom widgets through seeding process`); + await db.insert(customWidgetDefinitions).values(seedValues); + + console.log(`Created ${seedValues.length} default custom widgets through seeding process`); }; const seedBoardWidgetsAsync = async (db: Database) => {