Skip to content

ENG-1906 Add Content.content_type and backfill rows#1154

Merged
maparent merged 7 commits into
mainfrom
eng-1906-add-contentcontent_type-and-backfill-rows
Jun 29, 2026
Merged

ENG-1906 Add Content.content_type and backfill rows#1154
maparent merged 7 commits into
mainfrom
eng-1906-add-contentcontent_type-and-backfill-rows

Conversation

@maparent

@maparent maparent commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
discourse-graph Ready Ready Preview, Comment Jun 29, 2026 1:54pm

Request Review

@linear-code

linear-code Bot commented Jun 23, 2026

Copy link
Copy Markdown

ENG-1906

@graphite-app

graphite-app Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

PR size/scope check

This PR is over our review-size guideline.

  • Recommended: ~200 lines changed
  • Acceptable limit: up to 400 lines when well-scoped/self-contained
  • Preferred file count: fewer than 5 files

Please split this into smaller PRs unless there is a clear reason the changes need to land together.

If keeping it as one PR, please add a brief justification covering:

  • What single problem this PR solves
  • Why the files/changes are coupled

@supabase

supabase Bot commented Jun 23, 2026

Copy link
Copy Markdown

Updates to Preview Branch (eng-1906-add-contentcontent_type-and-backfill-rows) ↗︎

Deployments Status Updated
Database Mon, 29 Jun 2026 13:53:52 UTC
Services Mon, 29 Jun 2026 13:53:52 UTC
APIs Mon, 29 Jun 2026 13:53:52 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Mon, 29 Jun 2026 13:53:53 UTC
Migrations Mon, 29 Jun 2026 13:53:53 UTC
Seeding Mon, 29 Jun 2026 13:53:54 UTC
Edge Functions Mon, 29 Jun 2026 13:53:56 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

Open in Devin Review

Comment thread packages/database/supabase/schemas/content.sql
Comment thread packages/database/supabase/migrations/20260623144039_content_type_column.sql Outdated
Comment thread packages/database/supabase/migrations/20260623144039_content_type_column.sql Outdated
Comment thread packages/database/supabase/schemas/content.sql Outdated
Comment thread packages/database/src/dbTypes.ts Outdated
@maparent maparent force-pushed the eng-1906-add-contentcontent_type-and-backfill-rows branch from b8cce16 to 3f58bcb Compare June 26, 2026 13:41
@maparent maparent force-pushed the eng-1906-add-contentcontent_type-and-backfill-rows branch from 3f58bcb to e85f933 Compare June 26, 2026 14:59
@maparent maparent requested a review from mdroidian June 26, 2026 15:02
@mdroidian

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e85f9334c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

db_content.space_id,
db_content.last_modified,
db_content.part_of_id,
db_content.content_type

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Default content_type before inserting content

When a content payload omits content_type (the Roam content converter in this PR still does), db_content.content_type remains NULL. Because this INSERT explicitly lists the new NOT NULL column and passes that NULL, PostgreSQL will not apply the column default, so upsert_content fails before creating or updating the row. Set a fallback on db_content (or use DEFAULT/omit the column) before this VALUES entry.

Useful? React with 👍 / 👎.

document.metadata := '{}';
END IF;
IF document.content_type IS NULL THEN
document.content_type = 'text/plain';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep document defaults platform-specific

When upsert_documents is called without content_type, this fallback sets every new or updated document to text/plain regardless of the space platform. That disagrees with the migration backfill and upsert_content's inline-document path, which classify Roam documents as application/roam+json and Obsidian documents as text/obsidian+markdown; repeated upserts can overwrite the correct persisted type with text/plain. Use the selected v_platform default or preserve the existing value when the input omits it.

Useful? React with 👍 / 👎.

@mdroidian mdroidian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See codex's comments, probably worth addressing.

Also I’m going to approve this PR, but I want to note one concern around application/roam+json.

Right now this PR appears to backfill Roam Document.content_type values to application/roam+json, but we are not actually storing Roam JSON payloads yet. For the immediate v0 push/pull path between Obsidian and Roam, the stored content will be plain text/markdown-like content, not native Roam JSON.

If Document.content_type is intended to mean “native source document format,” then application/roam+json may make sense as a future-facing label. But if it is intended to describe the actual persisted payload, this seems premature and potentially misleading until we store the original Roam JSON/atJSON alongside the text representation.

I do not think this needs to block the PR, but I would like us to clarify that semantic before relying on content_type for behavior.

Copy link
Copy Markdown
Collaborator Author

It is absolutely intended to store the persisted payload. I put roam+json as the database default thinking this was imminent; and knowing we would set the value to roam+markdown explicitly in the meantime. I don't mind setting roam+markdown as the default, but changing defaults is a database migration, I was trying to avoid that. But we can do that as well. Let me know what you prefer.

@mdroidian

Copy link
Copy Markdown
Member

Thanks, that clarifies it. If content_type is meant to describe the persisted payload, then I’d prefer we do not use application/roam+json until we are actually storing native Roam JSON/atJSON.

For this PR, I think the cleanest path is to use the current persisted format as the value: probably text/roam+markdown if we want a Roam-specific label, or text/plain if the representation is not meaningfully distinct yet. Then when native Roam JSON lands, we can add a follow-up migration that changes new defaults and backfills only the rows whose payloads are actually JSON.

I’m not too worried about adding/changing a migration here since this PR is already introducing the column and backfill. I’d rather get the semantic right now than have downstream code start treating application/roam+json as JSON-parsable when it is not.

Copy link
Copy Markdown
Collaborator Author

Yes, text/roam+markdown is what I'm using in the sync. I'll update defaults accordingly

@maparent maparent merged commit 500da37 into main Jun 29, 2026
13 checks passed
@maparent maparent deleted the eng-1906-add-contentcontent_type-and-backfill-rows branch June 29, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants