Migrating Schemas Across Many Neon Projects Using DrizzleORM
Database-per-tenant setups need every tenant database kept on the same schema, and this walkthrough automates that across many Neon projects with DrizzleORM, the Neon API and GitHub Actions. A create script provisions a Neon project per customer. A generate script lists all projects, writes a per-tenant drizzle.config.ts, runs drizzle-kit generate, stores each connection string as an encrypted GitHub secret, and rewrites the workflow YAML to expose those secrets. A migrate script, triggered when a PR is merged to main, runs drizzle-kit migrate against every config so schema changes reach all tenants.
Related posts
- 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.
- Build a Database App with Drizzle ORM and Deno
Deno mediumAdeptDrizzle ORM can be used from Deno via npm compatibility to get type-safe CRUD access to PostgreSQL. The walkthrough installs drizzle-orm, drizzle-kit and pg, configures drizzle.config.ts with a DATABASE_URL, and shows two schema paths: introspecting an existing database with `drizzle-kit pull` or defining pgTable schemas in TypeScript and generating migrations with `drizzle-kit generate`. It then builds helper functions for inserting, querying, updating and deleting rows across two related tables using a pg Pool-backed Drizzle client, with the Deno flags (--env, --node-modules-dir) needed to make drizzle-kit work.
- 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.
- Inside a Kylon room, where people and agents build apps on Neon
Neon easyNovice
Kylon, a shared workspace where teams and AI agents build internal apps like CRMs and invoice trackers, maps its product directly onto Neon resources: one Neon project per workspace, one database per app, and one branch per draft. Agents apply schema migrations and changes to a branch copy of real data, a person reviews the preview, and production changes only on publish. Scale-to-zero makes many mostly idle agent-built databases affordable. The Neon API, point-in-time restore and MCP let agents provision, manage and undo changes without anyone opening a console.
- A database for every preview environment using Neon, GitHub Actions, and Vercel
Neon mediumAdept
Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases. Branches are isolated, are created in about a second regardless of database size, and bill only for unique data. A GitHub Actions pipeline creates a Neon branch per PR, runs Prisma migrations against it, deploys a Vercel preview wired to that branch, and comments the URLs on the PR. Merging applies migrations to the primary branch, deploys to production and deletes the preview branch.