# Packages
# README
gorm-multitenancy
Photo by Ashley McNamara, via ashleymcnamara/gophers (CC BY-NC-SA 4.0)
Introduction
Gorm-multitenancy is a Go package that provides a framework for implementing multitenancy in applications using GORM.
Multitenancy Approaches
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.
Features
- 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.
Database compatibility
The following databases are currently supported. Contributions for other drivers are welcome.
- PostgreSQL
Router Integration
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
Installation
go get -u github.com/bartventer/gorm-multitenancy/v6
Getting Started
Drivers
- PostgreSQL Guide
Middleware
Contributing
All contributions are welcome! Open a pull request to request a feature or submit a bug report.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.