This commit is contained in:
2026-09-13 20:15:48 +02:00
parent ffd32a6b63
commit 399f2be456
24 changed files with 2159 additions and 90 deletions
+15
View File
@@ -144,6 +144,21 @@ export const ensureAllItemsHaveSlugs = async () => {
}
};
export const ensureAllAlbumItemsHaveSlugs = async () => {
try {
const rows = await db`SELECT id FROM album_items WHERE slug IS NULL OR slug = ''`;
if (!rows || rows.length === 0) return;
console.log(`[ALBUM_SLUG_BACKFILL] Found ${rows.length} album item(s) missing slugs. Backfilling...`);
for (const row of rows) {
const newSlug = lib.generateSlug(11);
await db`UPDATE album_items SET slug = ${newSlug} WHERE id = ${row.id} AND (slug IS NULL OR slug = '')`;
}
console.log(`[ALBUM_SLUG_BACKFILL] Successfully backfilled ${rows.length} album item slug(s).`);
} catch (err) {
console.error('[ALBUM_SLUG_BACKFILL] Error during album item slug backfill:', err.message);
}
};
export const getEnableCleanup = () => {