Skip to content

Commit 4fdb3a7

Browse files
authored
Add JobMetricsPoint.job_id index (#3742)
1 parent af6a35a commit 4fdb3a7

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Add JobMetricsPoint.job_id index
2+
3+
Revision ID: ad8c50120507
4+
Revises: e9d81c97c042
5+
Create Date: 2026-04-03 10:43:18.440334+00:00
6+
7+
"""
8+
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "ad8c50120507"
13+
down_revision = "e9d81c97c042"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade() -> None:
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
with op.batch_alter_table("job_metrics_points", schema=None) as batch_op:
21+
batch_op.create_index(batch_op.f("ix_job_metrics_points_job_id"), ["job_id"], unique=False)
22+
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade() -> None:
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
with op.batch_alter_table("job_metrics_points", schema=None) as batch_op:
29+
batch_op.drop_index(batch_op.f("ix_job_metrics_points_job_id"))
30+
31+
# ### end Alembic commands ###

src/dstack/_internal/server/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ class JobMetricsPoint(BaseModel):
958958
UUIDType(binary=False), primary_key=True, default=uuid.uuid4
959959
)
960960

961-
job_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("jobs.id"))
961+
job_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("jobs.id"), index=True)
962962
job: Mapped["JobModel"] = relationship()
963963

964964
timestamp_micro: Mapped[int] = mapped_column(BigInteger)

0 commit comments

Comments
 (0)