Skip to content

Expand plan_versions.diff_unified to mediumtext#102

Merged
HamptonMakes merged 1 commit intomainfrom
hampton/diff-unified-mediumtext
Apr 30, 2026
Merged

Expand plan_versions.diff_unified to mediumtext#102
HamptonMakes merged 1 commit intomainfrom
hampton/diff-unified-mediumtext

Conversation

@HamptonMakes
Copy link
Copy Markdown
Collaborator

What

Bumps coplan_plan_versions.diff_unified from text (≈64KB MySQL limit) to mediumtext (≈16MB), matching content_markdown.

Why

Found while smoke-testing the new PUT /api/v1/plans/:id/content endpoint (#101) on a 5,000-line / 189KB plan with 10 scattered edits. The whole-file rewrite produced a unified diff > 64KB and the version insert blew up with:

ActiveRecord::ValueTooLong: Mysql2::Error: Data too long for column 'diff_unified' at row 1

This is a pre-existing schema limit affecting all four PlanVersion write paths (operations_controller, commit_session, plans_controller, replace_content) — the new endpoint just makes it trivially reachable since agents are encouraged to PUT entire files.

Verification

After applying the migration locally, the same 5,000-line PUT returns 201 in ~390ms with applied: 10 and exact roundtrip on current_content.

Full test suite still green: 765 examples, 0 failures.

The PUT /api/v1/plans/:id/content endpoint exposes a pre-existing
schema limit: diff_unified was 'text' (~64KB on MySQL) while
content_markdown is 'mediumtext' (~16MB). A whole-file PUT of any
plan whose unified diff exceeds 64KB (easy with multi-thousand-line
files) triggers ActiveRecord::ValueTooLong → 500.

Reproduced locally with a 5,000-line / 189KB plan and 10 scattered
edits. After the migration the same PUT returns 201 in ~390ms.

Affects all four PlanVersion write paths (operations_controller,
commit_session, plans_controller, replace_content) — schema-level
fix benefits them all.

Amp-Thread-ID: https://ampcode.com/threads/T-019dda86-f31b-7148-82b5-c5f1a59c4568
Co-authored-by: Amp <amp@ampcode.com>
Copy link
Copy Markdown

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

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: e7afb476ff

ℹ️ 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".

Comment on lines +9 to +10
def change
change_column :coplan_plan_versions, :diff_unified, :text, limit: 16.megabytes - 1
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 Rewrite migration using up/down for rollback safety

change_column is irreversible when used inside change, so rolling back this migration will raise ActiveRecord::IrreversibleMigration instead of restoring the old text definition. That makes deploy/database rollback paths fail when this migration has been applied (the same pattern is duplicated in the engine copy), which is a real operational risk for production rollbacks; use explicit up/down (or reversible) to define how to revert the column size change.

Useful? React with 👍 / 👎.

@HamptonMakes HamptonMakes merged commit 8d9be73 into main Apr 30, 2026
5 checks passed
@HamptonMakes HamptonMakes deleted the hampton/diff-unified-mediumtext branch April 30, 2026 15:11
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.

1 participant