Repository navigation
chore(openai-conversation): Remove Unused OpenAI Conversations module #1427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ayush8923
wants to merge
1
commit into
chore/cleanups-unwnated-modules
from
chore/remove-openai-conversations
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
backend/app/alembic/versions/095_drop_openai_conversation_table.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| """drop openai_conversation | ||
|
|
||
| Revision ID: 095 | ||
| Revises: 094 | ||
| Create Date: 2026-12-04 00:00:00.000000 | ||
|
|
||
| The Responses API and OpenAI Conversations modules were removed, so nothing reads or | ||
| writes this table any more. Rows are lost on upgrade; downgrade restores the schema | ||
| as it stood at 094 (an empty table) so older code can boot, not the data. | ||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| revision = "095" | ||
| down_revision = "094" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| op.drop_table("openai_conversation") | ||
|
|
||
|
|
||
| def downgrade(): | ||
| op.create_table( | ||
| "openai_conversation", | ||
| sa.Column( | ||
| "id", | ||
| sa.Integer(), | ||
| nullable=False, | ||
| comment="Unique identifier for the conversation record", | ||
| ), | ||
| sa.Column( | ||
| "response_id", | ||
| sa.String(), | ||
| nullable=False, | ||
| comment="OpenAI response identifier", | ||
| ), | ||
| sa.Column( | ||
| "ancestor_response_id", | ||
| sa.String(), | ||
| nullable=False, | ||
| comment="Root response ID for conversation threading", | ||
| ), | ||
| sa.Column( | ||
| "previous_response_id", | ||
| sa.String(), | ||
| nullable=True, | ||
| comment="Previous response ID in the conversation chain", | ||
| ), | ||
| sa.Column( | ||
| "user_question", | ||
| sa.String(), | ||
| nullable=False, | ||
| comment="User's question or input text", | ||
| ), | ||
| sa.Column( | ||
| "response", | ||
| sa.String(), | ||
| nullable=True, | ||
| comment="Response generated by OpenAI", | ||
| ), | ||
| sa.Column( | ||
| "model", | ||
| sa.String(), | ||
| nullable=False, | ||
| comment="Model used to generate the response", | ||
| ), | ||
| sa.Column( | ||
| "assistant_id", | ||
| sa.String(), | ||
| nullable=True, | ||
| comment="OpenAI assistant identifier if used", | ||
| ), | ||
| sa.Column( | ||
| "project_id", | ||
| sa.Integer(), | ||
| nullable=False, | ||
| comment="Reference to the project", | ||
| ), | ||
| sa.Column( | ||
| "organization_id", | ||
| sa.Integer(), | ||
| nullable=False, | ||
| comment="Reference to the organization", | ||
| ), | ||
| sa.Column( | ||
| "inserted_at", | ||
| sa.DateTime(), | ||
| nullable=False, | ||
| comment="Timestamp when the conversation was created", | ||
| ), | ||
| sa.Column( | ||
| "updated_at", | ||
| sa.DateTime(), | ||
| nullable=False, | ||
| comment="Timestamp when the conversation was last updated", | ||
| ), | ||
| sa.Column( | ||
| "deleted_at", | ||
| sa.DateTime(), | ||
| nullable=True, | ||
| comment="Timestamp when the conversation was deleted", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["organization_id"], ["organization.id"], ondelete="CASCADE" | ||
| ), | ||
| sa.ForeignKeyConstraint(["project_id"], ["project.id"], ondelete="CASCADE"), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| ) | ||
| op.create_index( | ||
| "ix_openai_conversation_project_id", "openai_conversation", ["project_id"] | ||
| ) | ||
| op.create_index( | ||
| "ix_openai_conversation_response_project_active", | ||
| "openai_conversation", | ||
| ["response_id", "project_id"], | ||
| postgresql_where=sa.text("deleted_at IS NULL"), | ||
| ) | ||
| op.create_index( | ||
| "ix_openai_conversation_ancestor_project_inserted_at_active", | ||
| "openai_conversation", | ||
| ["ancestor_response_id", "project_id", sa.text("inserted_at DESC")], | ||
| postgresql_where=sa.text("deleted_at IS NULL"), | ||
| ) | ||
| op.create_index( | ||
| "ix_openai_conversation_project_inserted_at_active", | ||
| "openai_conversation", | ||
| ["project_id", sa.text("inserted_at DESC")], | ||
| postgresql_where=sa.text("deleted_at IS NULL"), | ||
| ) | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
backend/app/api/docs/openai_conversation/get_by_ancestor_id.md
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
backend/app/api/docs/openai_conversation/get_by_response_id.md
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 (optional) During a deploy, admins on still-running old tasks get 500s on every project and organization hard delete. The migration runs before the new image takes over.
upgrade()dropsopenai_conversationwhile old code still maps it throughcascade_delete=Truerelationships. Fix: split the removal across two releases. Ship the code removal now and drop the table in a later migration, after no running code references it. Otherwise, document that the drop must run only after the old tasks are drained.Why this was flagged
deploy-staging-ecs.yml runs a one-off task with
alembic upgrade headin its "Run database migrations" step. Only after that does "Deploy to ECS and verify rollout" start, with a 15-minute timeout, so base-image tasks keep serving after 095 has run. In the base code,Project.openai_conversationsandOrganization.openai_conversationswereRelationship(..., cascade_delete=True). SQLModel turns that into an ORMdeletecascade without passive_deletes. Sosession.delete(project)inhard_delete_project(crud/project.py:180) and the organization hard delete both SELECT fromopenai_conversationbefore deleting. Once 095 has dropped the table, those SELECTs fail with UndefinedTable. Project and org hard deletes then return 500 on old tasks until the rollout finishes. The base branch has no such window. The DB-levelON DELETE CASCADEdoes not help, because the ORM query runs first. This is a cost beside the PR's purpose of removing the module, not something the purpose requires. Dropping the table in a later release avoids it.Verification: The migration drops the table outright:
op.drop_table("openai_conversation")(095_drop_openai_conversation_table.py:21-22). The base image still maps that table. On an old task, the hard-delete flush issues the collection SELECT against the dropped table. It fails with UndefinedTable / ProgrammingError, so the delete request returns 500. Nothing handles old code running after the upgrade.