-
Notifications
You must be signed in to change notification settings - Fork 10
Inconsistencies in data models and alembic migrations #266
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
16 commits
Select commit
Hold shift + click to select a range
9761018
data models
nishika26 70f0b01
creds table
nishika26 a58b813
inconsistency fix migration
nishika26 04737c9
remove project id as non nullable
nishika26 319db65
removing unneseccary
nishika26 14dfd43
project id non nullable creds table
nishika26 5ba1c5a
Merge branch 'main' into bug/inconsistent_db
nishika26 1386ced
Merge branch 'main' into bug/inconsistent_db
nishika26 f6b5c85
fixing formatting
nishika26 c9fbae9
test fixes
nishika26 c5e9a0d
small fixes
nishika26 da9d027
removing instruction column ambiguity
nishika26 cf6af85
Merge branch 'main' into bug/inconsistent_db
nishika26 8357880
conflicts
nishika26 b9a0fb7
small fixes
nishika26 0008806
fixing down revision
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
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
backend/app/alembic/versions/4aa1f48c6321_add_inconistency_fixes.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,84 @@ | ||
| """Fixing inconsistencies | ||
|
|
||
| Revision ID: 4aa1f48c6321 | ||
| Revises: 3389c67fdcb4 | ||
| Create Date: 2025-07-03 16:46:13.642386 | ||
|
|
||
| """ | ||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| import sqlmodel.sql.sqltypes | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "4aa1f48c6321" | ||
| down_revision = "f2589428c1d0" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| op.alter_column( | ||
| "collection", "project_id", existing_type=sa.INTEGER(), nullable=False | ||
| ) | ||
| op.alter_column( | ||
| "credential", | ||
| "inserted_at", | ||
| existing_type=postgresql.TIMESTAMP(), | ||
| nullable=False, | ||
| ) | ||
| op.alter_column( | ||
| "credential", "updated_at", existing_type=postgresql.TIMESTAMP(), nullable=False | ||
| ) | ||
| op.alter_column( | ||
| "credential", "project_id", existing_type=sa.INTEGER(), nullable=False | ||
| ) | ||
| op.create_index( | ||
| op.f("ix_openai_assistant_assistant_id"), | ||
| "openai_assistant", | ||
| ["assistant_id"], | ||
| unique=True, | ||
| ) | ||
| op.drop_constraint("project_organization_id_fkey", "project", type_="foreignkey") | ||
| op.create_foreign_key( | ||
| None, "project", "organization", ["organization_id"], ["id"], ondelete="CASCADE" | ||
| ) | ||
| op.drop_constraint("credential_project_id_fkey", "credential", type_="foreignkey") | ||
| op.create_foreign_key( | ||
| None, "credential", "project", ["project_id"], ["id"], ondelete="CASCADE" | ||
| ) | ||
|
|
||
|
nishika26 marked this conversation as resolved.
|
||
|
|
||
| def downgrade(): | ||
| op.drop_constraint(None, "project", type_="foreignkey") | ||
| op.create_foreign_key( | ||
| "project_organization_id_fkey", | ||
| "project", | ||
| "organization", | ||
| ["organization_id"], | ||
| ["id"], | ||
| ) | ||
| op.drop_index( | ||
| op.f("ix_openai_assistant_assistant_id"), table_name="openai_assistant" | ||
| ) | ||
| op.drop_constraint(None, "credential", type_="foreignkey") | ||
| op.create_foreign_key( | ||
| "credential_project_id_fkey", | ||
| "credential", | ||
| "project", | ||
| ["project_id"], | ||
| ["id"], | ||
| ondelete="SET NULL", | ||
| ) | ||
| op.alter_column( | ||
| "credential", "updated_at", existing_type=postgresql.TIMESTAMP(), nullable=True | ||
| ) | ||
| op.alter_column( | ||
| "credential", "inserted_at", existing_type=postgresql.TIMESTAMP(), nullable=True | ||
| ) | ||
| op.alter_column( | ||
| "collection", "project_id", existing_type=sa.INTEGER(), nullable=True | ||
| ) | ||
| op.alter_column( | ||
| "credential", "project_id", existing_type=sa.INTEGER(), nullable=True | ||
| ) | ||
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
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
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.
Fix revision ID inconsistency.
The revision ID in the docstring (line 4) shows
4aa1f48c6321but thedown_revision(line 15) showsf2589428c1d0, which doesn't match the revision ID from line 4. This creates confusion about the migration chain.Verify the correct
down_revisionvalue and update accordingly:Also applies to: 15-15
🤖 Prompt for AI Agents