From 373ffbff5fec28970118143cc2e270bcf32de08b Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Thu, 5 Mar 2026 11:55:28 +0000 Subject: [PATCH] Remove all placeholder articles automatically upon deployment Add logic to the seed function that deletes articles not present in the seed list, ensuring only valid content remains after deployment. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 791bdff6-f95e-4e8f-836a-f941239effa9 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/V5dWXpq Replit-Helium-Checkpoint-Created: true --- server/seed.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/seed.ts b/server/seed.ts index aa8033a..aa004ca 100644 --- a/server/seed.ts +++ b/server/seed.ts @@ -193,9 +193,18 @@ const seedArticles = [ ]; export async function seedDatabase() { + const validSlugs = new Set(seedArticles.map((a) => a.slug)); const existing = await storage.getArticles(); const existingSlugs = new Set(existing.map((a) => a.slug)); + const toDelete = existing.filter((a) => !validSlugs.has(a.slug)); + if (toDelete.length > 0) { + for (const article of toDelete) { + await db.execute(sql`DELETE FROM articles WHERE id = ${article.id}`); + } + console.log("Cleanup: removed " + toDelete.length + " articles not in seed list."); + } + let added = 0; for (const article of seedArticles) { if (existingSlugs.has(article.slug)) continue;