Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix(db): crash on MySQL — replace onConflictDoNothing with dialect-neutral pre-filter (#5995)

Thomasf1ee76c99cfb
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) => {