Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chg(dss): optimistically initialize document location state to ready for historical docs (#3244)

teo4ebe3edaf290
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260513010000_backfill_non_markdown_content_ready.sql b/rust/cloud-storage/macro_db_client/migrations/20260513010000_backfill_non_markdown_content_ready.sql
new file mode 100644
index 0000000000..7f69139e03
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260513010000_backfill_non_markdown_content_ready.sql
@@ -0,0 +1,23 @@
+-- Historical non-markdown documents should remain readable even when the
+-- legacy `uploaded` boolean is stale. Old S3 ObjectCreated events will not
+-- replay, so backfill existing non-markdown lifecycle rows optimistically to
+-- ready while preserving their canonical content location.
+--
+-- Markdown remains excluded because its canonical sync-service location must be
+-- verified by the dedicated markdown backfill/fallback workflow.
+
+UPDATE "Document"
+SET
+ "contentState" = 'ready',
+ "contentLocation" = CASE
+ WHEN "fileType" = 'docx' THEN 'converted_pdf'
+ ELSE 'object_storage'
+ END
+WHERE "fileType" IS DISTINCT FROM 'md'
+ AND (
+ "contentState" IS DISTINCT FROM 'ready'
+ OR "contentLocation" IS DISTINCT FROM CASE
+ WHEN "fileType" = 'docx' THEN 'converted_pdf'
+ ELSE 'object_storage'
+ END
+ );