diff --git a/src/backend/migrations/versions/016_vision_recipe_dir.py b/src/backend/migrations/versions/016_vision_recipe_dir.py new file mode 100644 index 0000000..3caa815 --- /dev/null +++ b/src/backend/migrations/versions/016_vision_recipe_dir.py @@ -0,0 +1,30 @@ +"""recipe_tasks.vision_recipe_dir: cartella della ricetta VisionSuite v2 (#46) + +Percorso relativo sotto upload_path della cartella immutabile che contiene +recipe.json e i file di meta (DXF, modelli .npz, ...). + +Revision ID: 016_vision_recipe_dir +Revises: 015_api_key_hash +Create Date: 2026-10-07 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + +revision: str = '016_vision_recipe_dir' +down_revision: Union[str, None] = '015_api_key_hash' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # batch: SQLite non sa fare DROP COLUMN nativo su tutte le versioni + with op.batch_alter_table('recipe_tasks') as batch: + batch.add_column(sa.Column('vision_recipe_dir', sa.String(500), nullable=True)) + + +def downgrade() -> None: + with op.batch_alter_table('recipe_tasks') as batch: + batch.drop_column('vision_recipe_dir') diff --git a/src/backend/models/orm/task.py b/src/backend/models/orm/task.py index 1e2d155..7f29422 100644 --- a/src/backend/models/orm/task.py +++ b/src/backend/models/orm/task.py @@ -18,7 +18,8 @@ if TYPE_CHECKING: TASK_TYPES = ("note", "measure", "drawing", "dxf_compare", "camera_measure") # Types the operator screen treats as "there are quotes to take here". -MEASURING_TASK_TYPES = ("measure", "camera_measure") +# dxf_compare produce quote come camera_measure (#46) +MEASURING_TASK_TYPES = ("measure", "camera_measure", "dxf_compare") class RecipeTask(Base): @@ -51,6 +52,9 @@ class RecipeTask(Base): # server routes it and never interprets it, which is what keeps VisionSuite # out of this container. vision_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True) + # Cartella immutabile (relativa a upload_path) con recipe.json e i file di + # meta della ricetta VisionSuite v2 (#46). + vision_recipe_dir: Mapped[Optional[str]] = mapped_column(String(500), nullable=True) # Relationships version: Mapped["RecipeVersion"] = relationship(back_populates="tasks") diff --git a/src/backend/services/recipe_service.py b/src/backend/services/recipe_service.py index 7faaeb1..f7d1789 100644 --- a/src/backend/services/recipe_service.py +++ b/src/backend/services/recipe_service.py @@ -115,6 +115,8 @@ async def _copy_tasks_to_version( # a camera_measure task unable to execute from the moment a # recipe with measurements is next edited. vision_json=task.vision_json, + # Cartella immutabile: basta il riferimento (#46). + vision_recipe_dir=task.vision_recipe_dir, ) db.add(new_task) await db.flush() # get new_task.id