Files
POPS/alembic/versions/0004_print_job_uuid_customer.py
Martin Hohenberg fe594e8675 Add job creation with UUID, STL upload/library, search, job log, TZ, and CLAUDE.md
- PrintJob: job_uuid (UUID4), customer, logs relationship
- JobLog model + migration 0004 (also includes job_logs table)
- POST /jobs: upload STL or select from library, auto-logs 'Job created'
- GET /jobs?q=: search by customer or filename across all statuses
- app/stl.py: STL_UPLOAD_DIR helper (from env, default /data/stl)
- docker-compose: named volume stl_files mounted at /data/stl
- .env.install: added STL_UPLOAD_DIR and TZ=Europe/Berlin
- CLAUDE.md: full project context for future sessions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 21:55:49 +02:00

40 lines
1.3 KiB
Python

"""add uuid, customer to print_jobs and job_logs table
Revision ID: 0004
Revises: 0003
Create Date: 2026-06-18
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "0004"
down_revision: Union[str, None] = "0003"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.add_column("print_jobs", sa.Column("job_uuid", sa.String(36), nullable=True))
op.add_column("print_jobs", sa.Column("customer", sa.String(200), nullable=True))
op.create_unique_constraint("uq_print_job_uuid", "print_jobs", ["job_uuid"])
op.create_table(
"job_logs",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("job_id", sa.Integer(), nullable=False),
sa.Column("message", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False, server_default=sa.text("CURRENT_TIMESTAMP")),
sa.ForeignKeyConstraint(["job_id"], ["print_jobs.id"], name="fk_joblog_job", ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
def downgrade() -> None:
op.drop_table("job_logs")
op.drop_constraint("uq_print_job_uuid", "print_jobs", type_="unique")
op.drop_column("print_jobs", "customer")
op.drop_column("print_jobs", "job_uuid")