# Wrap a multi-write operation that can half-succeed in one transaction

An operation that writes to three places and can stop after the first, wrapped so it either completes or does not.

Category: Data layer and migrations
Source: https://letsship.ai/use-cases/wrap-a-multi-write-in-a-transaction
Published: 2026-08-25

## Goal

Make a multi-write operation atomic so it cannot half-succeed.

## Acceptance criteria

- All writes happen in one transaction
- A test injects a failure partway and asserts nothing persisted
- Non-transactional side effects happen after the commit, not inside it
- The transaction is as short as it can be

## What lands as proof

A failure-injection test proving a mid-operation crash leaves no partial state behind.

## Prompt

Copy this to an agent to open the ticket:

```text
Create a Linear issue in my team and assign it to the SHIP agent.

Title: Make {operation} atomic

Description: Make a multi-write operation atomic so it cannot half-succeed.

Acceptance criteria:
- All writes happen in one transaction
- A test injects a failure partway and asserts nothing persisted
- Non-transactional side effects happen after the commit, not inside it
- The transaction is as short as it can be

Before you create the issue, find an operation in this repository that writes to several tables without a transaction and replace {operation}.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: make a multi-write operation atomic so it cannot half-succeed. Work that serves that outcome is in scope, and anything outside it is left for a separate ticket, so the pull request stays reviewable.

### How do I know the work is done?

The pull request carries the evidence, not only the diff. Here that means partial-failure test proving the whole operation rolls back, so a reviewer can confirm the result without reproducing the work locally.

### How much oversight does this need?

The run stops once the plan is written. Somebody reads the approach and approves it before any code exists, which is the cheapest moment to redirect the work.
