ragamuf

ragamuf

Who doesn’t want to go faster? Migrations in Elixir with Ecto are already quick. Still, we can go faster, especially when we need to onboard customers repeatedly in multi-tenant architectures.

Showing Posts 1 to 3

cjbottaro

cjbottaro

Neat!

We do something very similar. We have a “template” Pg schema that we dump/load on demand when a new tenant is created. The name of the schema is "__schema_$template", which is extremely likely to be to be unique when we run String.replace (or sed, can’t remember) on the dump output.

I’m a little confused how your #{prefix} works. Is that literally the name of your Pg schema?

One thing that I love about Ecto is how easy it is to do multitenancy. Between get_dynamic_repo, and default_options, it’s pretty easy to handle multietenancy (besides migrations, but that’s a story for another day).

Contrast that to Rails where they implemented first class support for multitenancy, but it’s very prescriptive about how it works… and further it makes a connection pool per tenant:man_facepalming:

ragamuf

ragamuf OP

Glad to hear that you have a similar process working well for you. Reusing the connection pool is a big deal. The prefix is just a placeholder like yours. I could have named it anything. The snapshot function returns a function that takes a specific prefix as an argument. This creates the unique schema for each tenant.

Did you run into any SSL invoking psql from System.cmd?

cjbottaro

cjbottaro

Nope, no SSL issues at all. We just use the Amazon managed certs for RDS and everything just works.

— All posts loaded —

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
ryanzidago
Hi all, In this article, I make the case for each test owning its setup. Usually I forbid my AI agents to use the setup callbacks; I mu...
New
zorn
As I’ve leaned into AI code generation on LocalCents, the volume I ship has climbed, and my worry shifted from any single change to the l...
New
pckrishnadas88
A while back, I had to process millions of database updates in a legacy system that was already hitting its 64 GB RAM limit, so scaling t...
New
smaller_infinity
I recently figured out how to the the Rust hotpath profiling crate running in an elixir benchmark script (for profiling NIFs). I had some...
New
pckrishnadas88
This article demonstrates how to build a minimal stateful process using only Elixir’s core concurrency primitives: spawn/1, send/2, recei...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews