Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 8 min read Case study mediumAdept

Lessons From a Zero-Downtime User-to-Org Migration

Neon migrated thousands of user accounts and more than 10M projects from user ownership to organization (team) ownership with no downtime, no breaking API changes, no API key rotation and no customer action. Backward compatibility came from a "migrated organization" fallback: user-scoped API requests that specify no org resolve to the user's migrated org. Billing moved through a "migrated billing account" that kept the original billing identifier, so invoices and the Stripe and Orb integrations kept working. Users were migrated one at a time over weeks, with ownership resolved at request time so systems tolerated a mixed state. The main advice for SaaS builders is to start with team accounts from day one.

Assumes: SaaS account and billing modelsAPI key scoping

Related posts

  • Database-per-User Architecture With Isolated Application Environments

    Neon mediumAdept

    Deploying a full copy of the application and its own Neon Postgres project per customer is justified mainly by data residency requirements and by letting customers control upgrade timing, not by per-customer customization, which turns each deployment into a separate product. Complexity moves from runtime routing into provisioning, a central control plane and catalog database that track feature enablement and deployed versions, and per-customer networking such as subdomains or custom URLs. The hardest part is versioning: when fixes are backported across release series, upgrades should be linearized through each minor series, and schema migrations should be idempotent (checking for existing columns and constraints) so backported changes don't conflict with later upgrades.

  • Why We Transitioned to Clerk for Authentication

    Turso mediumAdept

    Turso replaced its homegrown GitHub-only auth with Clerk to add Google login, passkeys, MFA and SSO/SAML without building auth in-house, choosing it over Auth.js, Auth0, Kinde and Hanko mainly for its hosted Account Portal and tight Next.js middleware integration. For the CLI, Clerk's one-minute session cookies were unsuitable, so they used JWT templates to issue 7-day long-lived tokens. Migration ran in three phases (dual-writing new users, bulk migrating existing users with Clerk's script, then cutting over), and users whose GitHub email had changed unnoticed were conservatively locked out to prevent account takeover. Next they plan to move from Account Portal to Clerk Elements for full UI customization.

  • Database-per-User Architecture With Shared Application Environments: How and Why

    Neon mediumAdept

    A single shared application environment serving many per-customer Neon Postgres databases keeps deployment simple, but every tenant database must stay at the same schema version and data residency is hard to offer. Tenant identification can come from a login field, a per-customer subdomain, or a lookup from the user's credentials. A catalog database maps users or JWT-carried customer IDs to Neon project IDs for connection routing, and it also holds tier and feature-flag context. Schema changes need either slow, backward-compatible rollouts using views and triggers, or pre-upgrade testing of each tenant database on branches. The control plane should be kept separate from the app so failures don't take both down.

  • Control Planes for Database-Per-User in Neon

    Neon mediumAdept

    A database-per-user architecture on Neon usually means one Neon project per customer, and that quickly needs a control plane to manage onboarding, monitoring and schema upgrades across many projects. The core piece is a catalog database: a separate Neon project holding an account manifest, per-project metadata such as deployed schema version, and billing data. It should use foreign keys, citext/uuid/timestamptz types and indexes. The practical advice is to start with the Neon console, neonctl and runbooks, automate the most time-consuming tasks first, and treat the control plane as an internal product. Tracking each database's migration version through tools like sqitch or Flyway is critical for rolling out upgrades safely.

  • Behind Modem.dev’s Product Velocity

    Neon mediumAdept

    Modem, a startup building an AI agent that centralizes user feedback from Slack, Discord and GitHub, uses Neon Postgres branching as its development workflow. Every PR with a migration gets its own database branch, where the migration is applied and a schema diff is posted to the PR. The process is repeated against a fresh branch at merge time to catch conflicting migrations, and each Vercel preview runs on an ephemeral branch with automatic cleanup. Two practical tips: script branching through the Neon CLI so coding agents can drive it, and tag OAuth refresh tokens with the originating branch so preview environments can't invalidate production tokens.

The quest for software engineering knowledge.

Look:
Layout: