Skip to content

Commit bf85ca5

Browse files
mihowclaude
andcommitted
fix(jobs): add missing migration for job_type_key choices
Job.job_type_key builds its choices from VALID_JOB_TYPES, so registry changes (post_processing and data_export job types added since the last migration) alter the field definition. The migration is state-only — no database schema change — but Django requires it, and the new makemigrations --check CI step fails without it. Documented the gotcha in the agent instructions. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bce961b commit bf85ca5

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

.agents/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Silent-bug classes that reviewers have caught repeatedly. None of these are visi
110110
- **Raise, don't return sentinels.** Failure paths raise exceptions (or surface DRF 4xx via serializer validation) — never return an empty/None "success" response on error.
111111
- **No `assert` in production code.** Assertions are stripped under `python -O`. Raise explicit exceptions.
112112
- **Model change ⇒ migration in the same PR.** Run `python manage.py makemigrations --check --dry-run` before pushing (CI enforces this). A missing migration discovered mid-branch that belongs to main gets its own PR branched from main.
113+
- **Changing `VALID_JOB_TYPES` requires a migration.** `Job.job_type_key` builds its `choices` from the registry, so adding/renaming a job type changes the field definition. The migration is state-only (no schema change), but Django still requires it, and it is easy to miss because nothing in the database schema changes.
113114

114115
## Development Commands
115116

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 4.2.10 on 2026-06-09 18:21
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("jobs", "0022_alter_job_logs_help_text"),
9+
]
10+
11+
operations = [
12+
migrations.AlterField(
13+
model_name="job",
14+
name="job_type_key",
15+
field=models.CharField(
16+
choices=[
17+
("ml", "ML pipeline"),
18+
("populate_captures_collection", "Populate capture set"),
19+
("data_storage_sync", "Data storage sync"),
20+
("unknown", "Unknown"),
21+
("data_export", "Data Export"),
22+
("post_processing", "Post Processing"),
23+
],
24+
default="unknown",
25+
max_length=255,
26+
verbose_name="Job Type",
27+
),
28+
),
29+
]

0 commit comments

Comments
 (0)