seed: odstrani brisanje ne-seed clankov (prezivijo deploy)
This commit is contained in:
parent
0dd5092e1b
commit
3fdf54ff55
@ -256,17 +256,12 @@ export async function seedDatabase() {
|
||||
OR excerpt LIKE '%„%' OR excerpt LIKE '%“%'
|
||||
`);
|
||||
|
||||
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.");
|
||||
}
|
||||
// NOTE: cleanup/delete of non-seed articles je ODSTRANJEN namenoma.
|
||||
// Seed samo doda ali posodobi svoje zacetne clanke; clankov, ki so bili
|
||||
// dodani kasneje (generator, admin), NE brise. Tako prezivijo vsak deploy.
|
||||
|
||||
let added = 0;
|
||||
let updated = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user