- New job_corrections table (append-only audit log) + migration
- Add approved / reviewed_by / reviewed_at columns to jobs
- PATCH /documents/{id} apply field-level corrections
- GET /documents/{id}/history return chronological audit trail
- POST /documents/{id}/approve lock final version (idempotent)
- Dotted field-path applier with root allow-list + list-index support
- Auto-clear `missing_field` review flag when required header keys filled
- Atomic batch apply: malformed path in batch rolls back all changes
- 22 new tests (11 repository-level, 11 API-level); 184 total passing
Co-Authored-By: adrian kuman firmansah <adriancuman@gmail.com>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""phase4 jobs table
|
|
|
|
Revision ID: ff8c14fbf8a0
|
|
Revises:
|
|
Create Date: 2026-04-25 15:54:18.579147
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "ff8c14fbf8a0"
|
|
down_revision: str | None = None
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"jobs",
|
|
sa.Column("job_id", sa.Uuid(), nullable=False),
|
|
sa.Column("status", sa.String(length=32), nullable=False),
|
|
sa.Column("source_kind", sa.String(length=16), nullable=False),
|
|
sa.Column("filename", sa.String(length=512), nullable=False),
|
|
sa.Column("blob_key", sa.String(length=512), nullable=True),
|
|
sa.Column("confidence", sa.Float(), nullable=True),
|
|
sa.Column("review_flags", sa.JSON(), nullable=False),
|
|
sa.Column("result", sa.JSON(), nullable=True),
|
|
sa.Column("error", sa.String(length=2048), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.PrimaryKeyConstraint("job_id"),
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table("jobs")
|
|
# ### end Alembic commands ###
|