fix: remove raw SQL query that may cause Docker build/runtime issues

Replace complex prisma.\ with simple Prisma findMany + JS stripping.
Now that entries are inherently small (base64 in separate blob namespace),
JS-based stripping is instant. Also fix migration to check flag before loading.
This commit is contained in:
AI Assistant
2026-02-27 23:53:37 +02:00
parent f8c19bb5b4
commit 578f6580a4
2 changed files with 17 additions and 62 deletions
@@ -83,7 +83,10 @@ function mergeBlobs(
...merged,
attachments: (merged.attachments ?? []).map((att) => {
const data = blobs.attachments?.[att.id];
if (data && (!att.data || att.data === "" || att.data === "__stripped__")) {
if (
data &&
(!att.data || att.data === "" || att.data === "__stripped__")
) {
return { ...att, data };
}
return att;
@@ -178,13 +181,13 @@ export async function migrateEntryBlobs(
storage: RegistryStorage,
blobStorage: RegistryStorage,
): Promise<number> {
// Use lightweight=true so PostgreSQL SQL strips data (works for old entries)
const all = await storage.exportAll({ lightweight: true });
// Check if we already migrated (marker key)
// Check migration flag FIRST to avoid any heavy loading
const migrated = await storage.get<boolean>("__blobs_migrated__");
if (migrated) return 0;
// Load entries (may be heavy on first migration — runs only once)
const all = await storage.exportAll();
// Load full data for entries that need migration
let count = 0;
for (const [key, value] of Object.entries(all)) {