-
Notifications
You must be signed in to change notification settings - Fork 8
Collection: making the module provider agnostic #548
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fd18a02
pushing the logic first
nishika26 364a2b5
fixing a delete mistake
nishika26 541e311
pushing everything together
nishika26 9ee861f
removing un-needed files
nishika26 9ed9ca5
adding a missed import
nishika26 aed5e24
adding more test cases
nishika26 0d6c444
fixing small issue
nishika26 97178fd
Merge branch 'main' into enhancement/collection_provider_agnostic
nishika26 24018c2
coderabbit fixes
nishika26 a6fb950
small test case fox
nishika26 26fa792
small fixes
nishika26 8b5427b
small coderabbit reviews
nishika26 f0a4134
Merge branch 'main' into enhancement/collection_provider_agnostic
nishika26 dfd06aa
add partial unique index
nishika26 af183e3
coderabbit review
nishika26 7503b7f
Merge branch 'main' into enhancement/collection_provider_agnostic
nishika26 c447769
fixing alembic migration
nishika26 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
backend/app/alembic/versions/041_extend_collection_table_for_provider_.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,116 @@ | ||
| """extend collection table for provider agnostic support | ||
|
|
||
| Revision ID: 042 | ||
| Revises: 041 | ||
| Create Date: 2026-01-15 16:53:19.495583 | ||
|
|
||
| """ | ||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| import sqlmodel.sql.sqltypes | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "042" | ||
| down_revision = "041" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
| provider_type = postgresql.ENUM( | ||
| "openai", | ||
| # aws | ||
| # gemini | ||
| name="providertype", | ||
| create_type=False, | ||
| ) | ||
|
|
||
|
|
||
| def upgrade(): | ||
| provider_type.create(op.get_bind(), checkfirst=True) | ||
| op.add_column( | ||
| "collection", | ||
| sa.Column( | ||
| "provider", | ||
| provider_type, | ||
| nullable=True, | ||
| comment="LLM provider used for this collection", | ||
| ), | ||
| ) | ||
| op.execute("UPDATE collection SET provider = 'openai' WHERE provider IS NULL") | ||
| op.alter_column("collection", "provider", nullable=False) | ||
| op.add_column( | ||
| "collection", | ||
| sa.Column( | ||
| "name", | ||
| sqlmodel.sql.sqltypes.AutoString(), | ||
| nullable=True, | ||
| comment="Name of the collection", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "collection", | ||
| sa.Column( | ||
| "description", | ||
| sqlmodel.sql.sqltypes.AutoString(), | ||
| nullable=True, | ||
| comment="Description of the collection", | ||
| ), | ||
| ) | ||
| op.alter_column( | ||
| "collection", | ||
| "llm_service_name", | ||
| existing_type=sa.VARCHAR(), | ||
| comment="Name of the LLM service", | ||
| existing_comment="Name of the LLM service provider", | ||
| existing_nullable=False, | ||
| ) | ||
| op.create_index( | ||
| "uq_collection_project_id_name_active", | ||
| "collection", | ||
| ["project_id", "name"], | ||
| unique=True, | ||
| postgresql_where="deleted_at IS NULL", | ||
| ) | ||
| op.drop_constraint( | ||
| op.f("collection_organization_id_fkey"), "collection", type_="foreignkey" | ||
| ) | ||
| op.drop_column("collection", "organization_id") | ||
|
|
||
|
|
||
| def downgrade(): | ||
| op.add_column( | ||
| "collection", | ||
| sa.Column( | ||
| "organization_id", | ||
| sa.INTEGER(), | ||
| autoincrement=False, | ||
| nullable=True, | ||
| comment="Reference to the organization", | ||
| ), | ||
| ) | ||
| op.execute( | ||
| """UPDATE collection SET organization_id = (SELECT organization_id FROM project | ||
| WHERE project.id = collection.project_id)""" | ||
| ) | ||
| op.alter_column("collection", "organization_id", nullable=False) | ||
| op.create_foreign_key( | ||
| op.f("collection_organization_id_fkey"), | ||
| "collection", | ||
| "organization", | ||
| ["organization_id"], | ||
| ["id"], | ||
| ondelete="CASCADE", | ||
| ) | ||
| op.drop_index("uq_collection_project_id_name_active", "collection", type_="unique") | ||
| op.alter_column( | ||
| "collection", | ||
| "llm_service_name", | ||
| existing_type=sa.VARCHAR(), | ||
| comment="Name of the LLM service provider", | ||
| existing_comment="Name of the LLM service", | ||
| existing_nullable=False, | ||
| ) | ||
| op.drop_column("collection", "description") | ||
| op.drop_column("collection", "name") | ||
| op.drop_column("collection", "provider") |
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 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
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.
Uh oh!
There was an error while loading. Please reload this page.