{"id":13412098,"url":"https://github.com/bartventer/gorm-multitenancy","last_synced_at":"2025-10-10T08:44:22.184Z","repository":{"id":214029414,"uuid":"735523531","full_name":"bartventer/gorm-multitenancy","owner":"bartventer","description":"🚀📦 Multi-tenancy support for GORM managed databases","archived":false,"fork":false,"pushed_at":"2025-08-18T09:05:36.000Z","size":924,"stargazers_count":66,"open_issues_count":13,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-21T15:58:57.092Z","etag":null,"topics":["echo","gin","go","gorm","iris","middleware","multitenancy","mysql","nethttp","postgres"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/v8","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bartventer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-25T08:22:53.000Z","updated_at":"2025-08-12T12:06:24.000Z","dependencies_parsed_at":"2024-02-27T03:25:43.615Z","dependency_job_id":"f0c64feb-040f-499f-9bd3-4062dec58ab2","html_url":"https://github.com/bartventer/gorm-multitenancy","commit_stats":null,"previous_names":["bartventer/gorm-multitenancy"],"tags_count":168,"template":false,"template_full_name":null,"purl":"pkg:github/bartventer/gorm-multitenancy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgorm-multitenancy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgorm-multitenancy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgorm-multitenancy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgorm-multitenancy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bartventer","download_url":"https://codeload.github.com/bartventer/gorm-multitenancy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgorm-multitenancy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272192669,"owners_count":24889452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["echo","gin","go","gorm","iris","middleware","multitenancy","mysql","nethttp","postgres"],"created_at":"2024-07-30T20:01:20.965Z","updated_at":"2025-10-10T08:44:22.113Z","avatar_url":"https://github.com/bartventer.png","language":"Go","readme":"# gorm-multitenancy\n\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n[![Go Reference](https://pkg.go.dev/badge/github.com/bartventer/gorm-multitenancy.svg)](https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/v8)\n[![Release](https://img.shields.io/github/release/bartventer/gorm-multitenancy.svg)](https://github.com/bartventer/gorm-multitenancy/releases/latest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bartventer/gorm-multitenancy/v8)](https://goreportcard.com/report/github.com/bartventer/gorm-multitenancy/v8)\n[![codecov](https://codecov.io/gh/bartventer/gorm-multitenancy/graph/badge.svg?token=6i0Pr1GFek)](https://codecov.io/gh/bartventer/gorm-multitenancy)\n[![Tests](https://github.com/bartventer/gorm-multitenancy/actions/workflows/default.yml/badge.svg)](https://github.com/bartventer/gorm-multitenancy/actions/workflows/default.yml)\n![GitHub issues](https://img.shields.io/github/issues/bartventer/gorm-multitenancy)\n[![License](https://img.shields.io/github/license/bartventer/gorm-multitenancy.svg)](LICENSE)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.imgur.com/bOZB8St.png\" title=\"GORM Multitenancy\" alt=\"GORM Multitenancy\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003csub\u003e\u003csmall\u003ePhoto by \u003ca href=\"https://github.com/ashleymcnamara\"\u003eAshley McNamara\u003c/a\u003e, via \u003ca href=\"https://github.com/ashleymcnamara/gophers\"\u003eashleymcnamara/gophers\u003c/a\u003e (CC BY-NC-SA 4.0)\u003c/small\u003e\u003c/sub\u003e\n\u003c/p\u003e\n\n## Overview\n\nGorm-multitenancy provides a Go framework for building multi-tenant applications, streamlining\ntenant management and model migrations. It abstracts multitenancy complexities through a unified,\ndatabase-agnostic API compatible with GORM.\n\n## Multitenancy Approaches\n\nThere are three common approaches to multitenancy in a database:\n\n- Shared database, shared schema\n- Shared database, separate schemas\n- Separate databases\n\nDepending on the database in use, this package utilizes either the _\"shared database, separate schemas\"_ or _\"separate databases\"_ strategy, ensuring a smooth integration with your existing database configuration through the provision of tailored drivers.\n\n## Features\n\n- **GORM Integration**: Simplifies [GORM](https://gorm.io/) usage in multi-tenant environments, offering a unified API alongside direct access to driver-specific APIs for flexibility.\n- **Custom Database Drivers**: Enhances existing drivers for easy multitenancy setup without altering initialization.\n- **HTTP Middleware**: Provides middleware for easy tenant context management in web applications.\n\n## Supported Databases\n\n| Database | Approach |\n|----------|----------|\n| PostgreSQL | Shared database, separate schemas |\n| MySQL | Separate databases |\n\n## Router Integration\n\n- Echo - [Guide](https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/middleware/echo/v8)\n- Gin - [Guide](https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/middleware/gin/v8)\n- Iris - [Guide](https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/middleware/iris/v8)\n- Net/HTTP - [Guide](https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/middleware/nethttp/v8)\n\n## Installation\n\nInstall the core package:\n\n```bash\ngo get -u github.com/bartventer/gorm-multitenancy/v8\n```\n\nInstall the database-specific driver:\n\n```bash\n# PostgreSQL\ngo get -u github.com/bartventer/gorm-multitenancy/postgres/v8\n\n# MySQL\ngo get -u github.com/bartventer/gorm-multitenancy/mysql/v8\n```\n\nOptionally, install the router-specific middleware:\n\n```bash\n# Echo\ngo get -u github.com/bartventer/gorm-multitenancy/middleware/echo/v8\n\n# Gin\ngo get -u github.com/bartventer/gorm-multitenancy/middleware/gin/v8\n\n# Iris\ngo get -u github.com/bartventer/gorm-multitenancy/middleware/iris/v8\n\n# Net/HTTP\ngo get -u github.com/bartventer/gorm-multitenancy/middleware/nethttp/v8\n```\n\n## Getting Started\n\nCheck out the [pkg.go.dev](https://pkg.go.dev/github.com/bartventer/gorm-multitenancy/v8) documentation for comprehensive guides and API references.\n\n### Running the Example Application\n\nFor a practical demonstration, you can run [the example application](./_examples/README.md). It showcases various configurations and usage scenarios.\n\n## Contributing\n\nAll contributions are welcome! See the [Contributing Guide](CONTRIBUTING.md) for more details.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":["Data Integration Frameworks","Database","数据库"],"sub_categories":["Database Tools","数据库工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartventer%2Fgorm-multitenancy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartventer%2Fgorm-multitenancy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartventer%2Fgorm-multitenancy/lists"}