Skip to content

Commit cba41c9

Browse files
committed
added indexes
1 parent a5c8a03 commit cba41c9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

backend/app/alembic/versions/d5747495bd7c_create_evaluation_run_table.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ def upgrade():
106106
op.create_index(
107107
op.f("ix_batch_job_project_id"), "batch_job", ["project_id"], unique=False
108108
)
109+
op.create_index(
110+
"idx_batch_job_status_org",
111+
"batch_job",
112+
["provider_status", "organization_id"],
113+
unique=False,
114+
)
115+
op.create_index(
116+
"idx_batch_job_status_project",
117+
"batch_job",
118+
["provider_status", "project_id"],
119+
unique=False,
120+
)
109121

110122
# Create evaluation_dataset table
111123
op.create_table(
@@ -202,10 +214,24 @@ def upgrade():
202214
op.create_index(
203215
op.f("ix_evaluation_run_run_name"), "evaluation_run", ["run_name"], unique=False
204216
)
217+
op.create_index(
218+
"idx_eval_run_status_org",
219+
"evaluation_run",
220+
["status", "organization_id"],
221+
unique=False,
222+
)
223+
op.create_index(
224+
"idx_eval_run_status_project",
225+
"evaluation_run",
226+
["status", "project_id"],
227+
unique=False,
228+
)
205229

206230

207231
def downgrade():
208232
# Drop evaluation_run table first (has foreign keys to batch_job and evaluation_dataset)
233+
op.drop_index("idx_eval_run_status_project", table_name="evaluation_run")
234+
op.drop_index("idx_eval_run_status_org", table_name="evaluation_run")
209235
op.drop_index(op.f("ix_evaluation_run_run_name"), table_name="evaluation_run")
210236
op.drop_table("evaluation_run")
211237

@@ -214,6 +240,8 @@ def downgrade():
214240
op.drop_table("evaluation_dataset")
215241

216242
# Drop batch_job table
243+
op.drop_index("idx_batch_job_status_project", table_name="batch_job")
244+
op.drop_index("idx_batch_job_status_org", table_name="batch_job")
217245
op.drop_index(op.f("ix_batch_job_project_id"), table_name="batch_job")
218246
op.drop_index(op.f("ix_batch_job_organization_id"), table_name="batch_job")
219247
op.drop_index(op.f("ix_batch_job_job_type"), table_name="batch_job")

0 commit comments

Comments
 (0)