Skip to content
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

fix: Add missing indexes in the vfolders table #1937

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""add-missing-vfolder-indexes

Revision ID: 41f332243bf9
Revises: 7ff52ff68bfc
Create Date: 2024-02-28 17:27:40.387122

"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "41f332243bf9"
down_revision = "7ff52ff68bfc"
branch_labels = None
depends_on = None


def upgrade():
op.create_index(op.f("ix_vfolders_host"), "vfolders", ["host"], unique=False)
op.create_index(
op.f("ix_vfolders_ownership_type"), "vfolders", ["ownership_type"], unique=False
)
op.create_index(op.f("ix_vfolders_status"), "vfolders", ["status"], unique=False)
op.create_index(op.f("ix_vfolders_usage_mode"), "vfolders", ["usage_mode"], unique=False)


def downgrade():
op.drop_index(op.f("ix_vfolders_usage_mode"), table_name="vfolders")
op.drop_index(op.f("ix_vfolders_status"), table_name="vfolders")
op.drop_index(op.f("ix_vfolders_ownership_type"), table_name="vfolders")
op.drop_index(op.f("ix_vfolders_host"), table_name="vfolders")
1 change: 1 addition & 0 deletions src/ai/backend/manager/models/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ async def handle_kernel_exception(
default=KernelRole.COMPUTE,
server_default=KernelRole.COMPUTE.name,
nullable=False,
index=True,
),
sa.Column("status_changed", sa.DateTime(timezone=True), nullable=True, index=True),
sa.Column("status_info", sa.Unicode(), nullable=True, default=sa.null()),
Expand Down
5 changes: 4 additions & 1 deletion src/ai/backend/manager/models/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ class VFolderCloneInfo(NamedTuple):
metadata,
IDColumn("id"),
# host will be '' if vFolder is unmanaged
sa.Column("host", sa.String(length=128), nullable=False),
sa.Column("host", sa.String(length=128), nullable=False, index=True),
sa.Column("quota_scope_id", QuotaScopeIDType, nullable=False),
sa.Column("name", sa.String(length=64), nullable=False, index=True),
sa.Column(
"usage_mode",
EnumValueType(VFolderUsageMode),
default=VFolderUsageMode.GENERAL,
nullable=False,
index=True,
),
sa.Column("permission", EnumValueType(VFolderPermission), default=VFolderPermission.READ_WRITE),
sa.Column("max_files", sa.Integer(), default=1000),
Expand All @@ -248,6 +249,7 @@ class VFolderCloneInfo(NamedTuple):
EnumValueType(VFolderOwnershipType),
default=VFolderOwnershipType.USER,
nullable=False,
index=True,
),
sa.Column("user", GUID, sa.ForeignKey("users.uuid"), nullable=True), # owner if user vfolder
sa.Column("group", GUID, sa.ForeignKey("groups.id"), nullable=True), # owner if project vfolder
Expand All @@ -258,6 +260,7 @@ class VFolderCloneInfo(NamedTuple):
default=VFolderOperationStatus.READY,
server_default=VFolderOperationStatus.READY,
nullable=False,
index=True,
),
# status_history records the most recent status changes for each status
# e.g)
Expand Down
Loading