Multi-tenant SaaS

Our SaaS application is a rewrite from an older application that had a shared database for the SaaS solution. Basically I didn’t know better.

In one of my former jobs, their SaaS application used Java/Spring and created a new database for each customer. That made life quite a bit simpler, but testing was a bit of a pain iirc.

Recently I came across a Django package that sets the Postgres search path to a tenant schema, to customers had their own schema, and some shared tables were possible. The very thought that you didn’t have to take into account which customer was querying and could just use default Django functionality made me a very happy panda.

I started making test cases for the biggest migration so far; from a shared database, to a schema based one. Luckily a lot of logic was already there, so it was clear what had to be done.

It was a lot of work, but the migration succeeded without “dude, where’s my data”, or “hey, those aren’t my customers”. Actually nobody noticed, except for some stupid little things that weren’t directly related to the migration.

Now removing all unnecessary relations and exceptions as we go, making everything very neat, and everything properly tested across all tenants.

Show your support

Clapping shows how much you appreciated pedro’s story.