Skip to content
all entries

What an Alchemy database layer can swap

An Effect layer can supply a different database to the same application service. Moving a database that already holds data takes a migration plan.

I was taking notes on Sam Goodwin’s Alchemy interview on Syntax. His example puts the application’s database dependency behind an Effect service. A layer supplies that service, so an environment can choose a different implementation if it satisfies the same contract.1

Alchemy documents a Cloudflare Workers and Drizzle setup for either Neon or PlanetScale Postgres. The provider choice lives in the layer. The queries still have to behave as expected against the chosen database.23

I’d review a provider change in two parts. First run the application’s queries and schema migrations against the target database. Then plan how to copy and verify the existing rows before cutover. The layer gives me a place to change the connection. Those checks tell me whether I can move the workload and its data.

Footnotes

  1. Sam Goodwin’s Alchemy interview on Syntax, database discussion at 10:25 and 13:09. ↩

  2. Effect’s guide to layers. ↩

  3. Alchemy’s database integrations and migration guidance. ↩