-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(BA-584): Remove foreign key constraint from
EndpointRow.image
c…
…olumn (#3599) Backported-from: main (25.1) Backported-to: 24.03 Backport-of: 3599
- Loading branch information
1 parent
85df0f9
commit 3c3d4f8
Showing
4 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
Remove foreign key constraint from `EndpointRow.image` column. |
37 changes: 37 additions & 0 deletions
37
...kend/manager/models/alembic/versions/ecc9f6322be4_remove_fk_constraint_from_endpoints_.py
This file contains 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,37 @@ | ||
"""Remove foreign key constraint from endpoints.image column | ||
Revision ID: ecc9f6322be4 | ||
Revises: f6ca2f2d04c1 | ||
Create Date: 2025-02-07 00:58:05.211395 | ||
""" | ||
|
||
from alembic import op | ||
|
||
from ai.backend.manager.models.base import GUID | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "ecc9f6322be4" | ||
down_revision = "f6ca2f2d04c1" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.drop_constraint("fk_endpoints_image_images", "endpoints", type_="foreignkey") | ||
op.alter_column("endpoints", "image", existing_type=GUID, nullable=True) | ||
op.create_check_constraint( | ||
constraint_name="ck_image_required_unless_destroyed", | ||
table_name="endpoints", | ||
condition="lifecycle_stage = 'destroyed' OR image IS NOT NULL", | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.create_foreign_key( | ||
"fk_endpoints_image_images", "endpoints", "images", ["image"], ["id"], ondelete="RESTRICT" | ||
) | ||
op.alter_column("endpoints", "image", existing_type=GUID, nullable=False) | ||
op.drop_constraint( | ||
constraint_name="ck_image_required_unless_destroyed", table_name="endpoints", type_="check" | ||
) |
This file contains 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 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