Photo by Ashley McNamara, via ashleymcnamara/gophers (CC BY-NC-SA 4.0)
Gorm-multitenancy is a Go package that provides a framework for implementing multitenancy in applications using GORM.
There are three common approaches to multitenancy in a database:
- Shared database, shared schema
- Shared database, separate schemas
- Separate databases
This package adopts the 'shared database, separate schemas' approach, providing custom drivers for seamless integration with your existing database setup.
- GORM Integration: Leverages the gorm ORM to manage the database, facilitating easy integration with your existing GORM setup.
- Custom Database Drivers: Provides drop-in replacements for existing drivers, enabling multitenancy without the need for initialization reconfiguration.
- HTTP Middleware: Offers middleware for seamless integration with popular routers, making it easy to manage tenant context in your application.
The following databases are currently supported. Contributions for other drivers are welcome.
- PostgreSQL
This package includes middleware that can be used with the routers listed below for seamless integration with the database drivers. While not a requirement, these routers are fully compatible with the provided middleware. Contributions for other routers are welcome.
- Echo
- Net/HTTP
go get -u github.com/bartventer/gorm-multitenancy/v6
- PostgreSQL Guide
All contributions are welcome! Open a pull request to request a feature or submit a bug report.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.