Multi Tenancy base example using TypeORM and NestJS. Article about the project: https://medium.com/@henrique.weiand/nestjs-typeorm-and-multi-tenancy-a7f6176e8319
- Rename .env.example to .env
- Execute the docker
docker-compose up -d
; - Run once the app
yarn start:dev
- Stop the app, and go to the tenant table inside the nestjs-typeorm-multi-tenancy database.
- Insert the connection data as needed (it will create new database)
- Use the id to make requests. Inform tenant-id in the headers
If you want to generate migrations based on the entities, you can do it by running yarn typeorm:generate
, then, when you start the application, it will run the migrations for all bases.