55Create Date: 2026-06-26
66
77Distinct from the legacy `template` table (int PK + uploaded PDF). This is the
8- standards registry keyed by `form_type`, holding incident-schema field definitions and
9- mappings. `fields` and `field_mappings_from_incident` use sa.JSON for
10- consistency with migrations 001/002 and SQLite test-harness compatibility.
8+ standards registry keyed by `form_type`, holding incident-schema field definitions
9+ plus their visual layout. The `fields` JSON column (list of TemplateField objects,
10+ each with a nested `layout`) uses sa.JSON for consistency with migrations 001/002
11+ and SQLite test-harness compatibility.
1112
1213`form_type` is a plain VARCHAR (not a Postgres ENUM): custom jurisdictions are
1314registered here and are not part of the built-in FormType enum.
@@ -31,10 +32,9 @@ def upgrade() -> None:
3132 sa .Column ("template_id" , sa .Uuid (), primary_key = True ),
3233 sa .Column ("form_type" , sqlmodel .sql .sqltypes .AutoString , nullable = False ),
3334 sa .Column ("display_name" , sqlmodel .sql .sqltypes .AutoString , nullable = False ),
34- sa .Column ("jurisdiction" , sqlmodel .sql .sqltypes .AutoString , nullable = False ),
35+ sa .Column ("jurisdiction" , sqlmodel .sql .sqltypes .AutoString , nullable = True ),
3536 sa .Column ("agency_type" , sqlmodel .sql .sqltypes .AutoString , nullable = True ),
3637 sa .Column ("fields" , sa .JSON , nullable = False ),
37- sa .Column ("field_mappings_from_incident" , sa .JSON , nullable = False ),
3838 sa .Column ("source_standard" , sqlmodel .sql .sqltypes .AutoString , nullable = True ),
3939 sa .Column ("pdf_template_ref" , sqlmodel .sql .sqltypes .AutoString , nullable = True ),
4040 sa .Column ("version" , sqlmodel .sql .sqltypes .AutoString , nullable = False ),
0 commit comments