Skip to content

Pause scheduled purchase fails with valid_status CHECK constraint violation (Planned 6.1) #772

Closed

Description

@cristim

Symptom (Planned Purchases 6.1)

Clicking the "Pause" button next to a scheduled purchase fails with:

Failed to pause purchase: execution b030ec47-5c02-46b6-b97f-1df38da3c61b cannot be paused: ERROR: new row for relation "purchase_executions" violates check constraint "valid_status" (SQLSTATE 23514)

The DB check constraint valid_status on purchase_executions doesn't accept whatever status the pause flow is trying to write.

Likely causes (verify)

  1. The pause handler writes a status string (e.g. paused) that is not in the valid_status CHECK constraint enum on purchase_executions. Either:

    • Add paused (and any adjacent states) to the CHECK constraint via a migration, OR
    • Change the handler to use an existing valid status (less likely correct -- the action is genuinely pausing).
  2. The status transition is from a state where Pause shouldn't be valid (e.g. trying to pause an already-completed execution), and the handler doesn't pre-validate.

Acceptance

  • Clicking Pause on a scheduled (pending) execution succeeds, the row's status becomes the documented "paused" state, and the toast confirms.
  • A new migration adds the paused status to the valid_status CHECK constraint (using a transactional ALTER TABLE pattern).
  • Pre-validate in the handler: return a clean 4xx with a clear message when the source status isn't pause-eligible (do NOT return a generic 500 with the SQL error string).
  • Regression test exercises the pause transition end-to-end with both eligible and ineligible source statuses.

Source

Planned Purchases 6.1, exploratory testing 2026-05-27.

Activity

  1. added a commit that references this issue on May 28, 2026
    dca027c
  2. cristim commented on May 28, 2026

    @cristim
    MemberAuthor

    Verified shipped: PR #779 (commit dca027c, merged 2026-05-28) is in feat/multicloud-web-frontend. Migration 000055_add_paused_status.up.sql adds 'paused' to valid_status CHECK constraint. Tests in handler_purchases_test.go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions