a tool for shared writing and social publishing

don't delete old records

+6 -30
+6 -30
app/api/inngest/functions/migrate_user_to_standard.ts
··· 385 385 } 386 386 } 387 387 388 - // Step 7: Delete old records from our database tables 389 - await step.run("delete-old-db-records", async () => { 390 - const oldPubUris = Object.keys(publicationUriMap).filter(uri => 391 - new AtUri(uri).collection === "pub.leaflet.publication" 392 - ); 393 - const oldDocUris = Object.keys(documentUriMap).filter(uri => 394 - new AtUri(uri).collection === "pub.leaflet.document" 395 - ); 396 - 397 - // NOTE: We intentionally keep old documents_in_publications entries. 398 - // New entries are created in Step 4 with the new URIs, but the old entries 399 - // should remain so that notifications and other references that point to 400 - // old document/publication URIs can still look up the relationship. 401 - 402 - // Delete from documents (old document URIs) 403 - if (oldDocUris.length > 0) { 404 - await supabaseServerClient 405 - .from("documents") 406 - .delete() 407 - .in("uri", oldDocUris); 408 - } 409 - 410 - // Delete from publications (old publication URIs) 411 - if (oldPubUris.length > 0) { 412 - await supabaseServerClient 413 - .from("publications") 414 - .delete() 415 - .in("uri", oldPubUris); 416 - } 417 - }); 388 + // NOTE: We intentionally keep old documents, publications, and documents_in_publications entries. 389 + // New entries are created with the new URIs, but the old entries remain so that: 390 + // 1. Notifications referencing old document/publication URIs can still resolve 391 + // 2. External references (e.g., from other AT Proto apps) to old URIs continue to work 392 + // 3. The normalization layer handles both schemas transparently for reads 393 + // Old records are also kept on the user's PDS so existing AT-URI references remain valid. 418 394 419 395 return { 420 396 success: stats.errors.length === 0,