# Migrating production backends from n8n to Cloudflare Workers

> We moved our production backends from self-hosted n8n to Cloudflare Workers one service at a time, with a written decision for every node and tests that compare the old and the new code.

- Service: Automation and migrations
- Stack: Cloudflare Workers, TypeScript, Queues, Hyperdrive, PostgreSQL, n8n
- Canonical: https://jamm-automation.com/cases/workers-migration/
- Updated: 2026-11-29

## Manual

Production backends ran as n8n workflows on a self-hosted server; the sites ran on Cloudflare Pages.

- **Logic:** business rules lived inside visual nodes, hard to cover with tests or review as code.
- **Constraint:** partners and members relied on these services, so the move had to go step by step and stay reversible.

## System

We migrated to Cloudflare Workers in TypeScript one service at a time, not in one big switch.

- **Porting log:** every n8n node got a written decision: ported to a named function, or dropped with a reason.
- **Differential tests:** the same inputs went to the old and the new code and the answers were compared; for the dashboard API, 128 inputs across 11 routes.
- **Triggers:** n8n webhooks and schedules became Cron Triggers and Queues, with dead-letter queues for messages that keep failing.
- **Data:** PostgreSQL stayed in place, reached through Hyperdrive.

## Autopilot

Every Worker ships through scripted gates and rolls back in one step.

- **Deploy gates:** clean git, tests, type check, health and smoke checks; production steps run only after the owner confirms.
- **Rollback:** one step to the previous Worker version; the archived n8n flows can still be restored.
- **Cutover:** the old stack was removed only after the new one was running in production.
