Database per tenant infrastructure

The previous two posts in this series talked about the infrastructure and the setup of the catalog database and how to run migrations on that. This post will dive into the code that allows you to connect to a specific database of a tenant.

This blog is part of a larger series of blogs in which I explain how to set up a database-per-tenant architecture. Most of what this blog touches can still be used without reading the whole series.

TL;DR: All code, templates, and pipelines can be found in my repository.