Skip to content

Conversation

Weves
Copy link
Contributor

@Weves Weves commented Sep 11, 2025

Description

[Provide a brief description of the changes in this PR]

How Has This Been Tested?

[Describe the tests you ran to verify your changes]

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Summary by cubic

Merge Prompt into Persona and raise prompt size limits to 5,000,000 characters. This simplifies the schema and supports very large prompts.

  • Migration

    • Merge Prompt into Persona; drop prompt and persona__prompt tables; remove chat_message.prompt_id.
    • Move prompt data to persona; set defaults for missing values; orphan prompts are discarded.
  • Refactors

    • Increase system_prompt/task_prompt limit to 5,000,000 and align models with a PROMPT_LENGTH constant.

@Weves Weves requested a review from a team as a code owner September 11, 2025 01:56
Copy link

vercel bot commented Sep 11, 2025

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

Project Deployment Preview Comments Updated (UTC)
internal-search Ready Ready Preview Comment Sep 11, 2025 2:12am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR improves database migrations by consolidating prompt-related functionality and fixing prompt length limits. The changes include three main components:

  1. Model Updates: The models.py file introduces a PROMPT_LENGTH constant set to 5,000,000 characters and updates the Persona model's system_prompt and task_prompt fields to use this new limit, replacing the previous 8,000 character restriction.

  2. Schema Consolidation: The existing migration abbfec3a5ac5_merge_prompt_into_persona.py is significantly improved to merge the separate prompt table into the persona table, eliminating complex many-to-many relationships. This migration removes defensive existence checks for a cleaner execution and migrates existing prompt data directly into persona records.

  3. Follow-up Migration: A new migration b7ec9b5b505f_adjust_prompt_length.py is added to specifically handle the prompt length adjustment from 8,000 to 5,000,000 characters in the persona table.

These changes align with simplifying the database architecture by removing unnecessary abstraction layers. Previously, personas could have multiple prompts through a junction table, but this complexity was eliminated since personas typically use a single prompt. The massive increase in prompt length (from 8K to 5M characters) enables support for much more detailed system instructions and complex AI prompts. The migrations work together to first consolidate the schema, then adjust the length limits to match the new model definitions.

Confidence score: 1/5

  • This PR has critical issues that will cause migration failures and should not be merged without fixes
  • Score reflects a serious table name bug in the new migration's downgrade function that references a non-existent table
  • Pay close attention to b7ec9b5b505f_adjust_prompt_length.py which has incorrect table references in the downgrade function

3 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment on lines 85 to 88
op.drop_table("persona__prompt")

# Step 6: Drop the prompt table (if it exists)
if "prompt" in existing_tables:
op.drop_table("prompt")
op.drop_table("prompt")
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Tables may not exist in all environments - could cause migration failures

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 3 files

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@Weves Weves merged commit 82b5f80 into main Sep 11, 2025
52 of 53 checks passed
@Weves Weves deleted the improve-migration branch September 11, 2025 02:29
AnkitTukatek pushed a commit to TukaTek/onyx that referenced this pull request Sep 23, 2025
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