At Vesta, we have a multi-tenant application where tenant data is logically separated in our Postgres instance by a
tenant_id column on entity tables. As we’ve grown, we’ve had to delete some tenant data. Although I’ve done it manually a few times in
psql, manually deleting rows is dangerous, so I decided to write a script to delete tenants for us.
We use EF Core for all of our database interactions at Vesta, so our entire database schema is represented in our
DbContexts contain entity metadata, I wrote the script against that data.