gorm-multitenancy

🚀📦 Multi-tenancy support for GORM managed databases

APACHE-2.0 License

Stars
39

Bot releases are visible (Hide)

gorm-multitenancy - v8.5.0 Latest Release

Published by github-actions[bot] 2 months ago

8.5.0 (2024-08-18)

Bug Fixes

  • all: Update go version to 1.23 (95ab6a8)
  • mysql: Bump dependencies (f5df67c)
  • mysql: Update UseDatabase error handling (3cd1127)
  • postgres: Bump dependencies (2918c58)
  • postgres: Update SetSearchPath error handling (78de424)

Features

  • drivertest: Add conformance tests for data isolation (47d286f)
  • mysql: Add advisory locks and backoff retry logic (2faa723)
  • pkg/backoff: Add package for exponential backoff retry logic (dc27976)
  • pkg/driver: Add ParseDSNQueryParams generic function (6175105)
  • pkg/migrator: Add FNV-1a lock key hashing function (b95f42c)
  • postgres: Add advisory locks and backoff retry logic (2d54f4e)
gorm-multitenancy - v8.4.0

Published by github-actions[bot] 3 months ago

8.4.0 (2024-07-23)

Features

  • pkg/migrator: Introduce migrator Package (f58170e)
  • postgres, mysql: Update Drivers to Utilize migrator Package (f5f009b)

Performance Improvements

  • middleware/all: Optimize Context Keys String Method (b307429)
  • middleware/nethttp: Optimize DefaultTenantFromSubdomain Function (7e6439a)
  • middleware/nethttp: Optimize ExtractSubdomain Function (73a64df)
  • postgres: Optimize SetSearchPath Function (6a84bdc)
gorm-multitenancy - v8.3.1

Published by github-actions[bot] 3 months ago

gorm-multitenancy - v8.3.0

Published by github-actions[bot] 4 months ago

8.3.0 (2024-07-08)

Bug Fixes

  • middleware/all: Update Middleware Initialization for TenantGetters (2b47c2a)

Features

  • middleware/gin: Introduce gin Middleware (b5dca9c)
gorm-multitenancy - v8.2.0

Published by github-actions[bot] 4 months ago

8.2.0 (2024-07-07)

Bug Fixes

  • deps: Bump dependencies (f2bbbae)

Features

  • all: Update Drivers to Support URL Type for Custom URL Handling (71f512a)
  • mysql/internal: Introduce dsn Package for DSN Parsing (9a5ea5a)
  • Update OpenDB signature for additional Options (a4f289a)
  • Update OpenDBURL Method Signature for URL Type (c5ffa1b)
  • pkg/driver: Introduce URL Type for Custom URL Handling (ee70208)
gorm-multitenancy - v8.1.0

Published by github-actions[bot] 4 months ago

8.1.0 (2024-07-06)

Features

  • Add OpenDB function for blank import database initialization (753b0cb)

[!TIP]
For a comprehensive guide on how to use the new feature, please refer to the Usage Guide.

gorm-multitenancy - v8.0.0

Published by github-actions[bot] 4 months ago

8.0.0 (2024-07-05)

[!WARNING]
The gorm-multitenancy package has been updated to Version 8, introducing significant changes to the project structure, module names, and import paths. Developers are advised to review the following breaking changes and update their projects accordingly to align with the latest version.

[!TIP]
For a comprehensive guide on how to use the new features and changes in Version 8, please refer to the Usage Guide.

Bug Fixes

  • deps: Bump dependencies (f739e36)
  • middleware/all: Update dependencies (1124fb6)
  • postgres: Update dependencies (200b22c)

chore

Code Refactoring

  • postgres: Internalize Migration Options Handling (31676bf)
  • postgres: Rename CreateSchemaForTenant to MigrateTenantModels (de42b44)
  • postgres: Simplify Driver Architecture (01fac17)
  • Update Tenant Models (753679a)
  • driver: Update TenantTabler Interface (40c8513)
  • drivers: Restructure drivers directory (e252589)
  • pkg: Move scopes package to pkg directory (125c314)

Features

  • Add Adapter interface and driverMux implementation (aa3115b)
  • Introduce DB Struct for Unified Database Operations (79a5ae3)
  • context: Decentralize tenant and migration context management (b4e95ec)
  • middlware/echo: Add alias for ExtractSubdomain from nethttpmw package (b98e183)
  • pkg: Add drivertest Package for Driver Conformance Testing (42248db)
  • pkg/gmterrors: Add error handling package (a9f7041)
  • pkg/logext: Add logext package (b199edc)
  • pkg/namespace: Add namespace validation package (2af67e8)
  • Add support for MySQL driver (10a28dc)

BREAKING CHANGES

  • The gorm-multitenancy package has been updated to Version 8, introducing significant changes to the project structure, module names, and import paths. Developers are advised to update their projects accordingly to align with the latest version and take advantage of the new features and improvements.

    Key Changes:

    -github.com/bartventer/gorm-multitenancy/v7
    +github.com/bartventer/gorm-multitenancy/v8
    
    -github.com/bartventer/gorm-multitenancy/mysql/v7
    +github.com/bartventer/gorm-multitenancy/mysql/v8
    
    -github.com/bartventer/gorm-multitenancy/postgres/v7
    +github.com/bartventer/gorm-multitenancy/postgres/v8
    
    -github.com/bartventer/gorm-multitenancy/middleware/echo/v7
    +github.com/bartventer/gorm-multitenancy/middleware/echo/v8
    
    -github.com/bartventer/gorm-multitenancy/middleware/nethttp/v7
    +github.com/bartventer/gorm-multitenancy/middleware/nethttp/v8
    
  • postgres: The MigrationOptions struct within the postgres driver has been removed from the public API and is now managed internally by the driver. This change streamlines the migration process and enhances the driver's internal logic, ensuring a more robust and maintainable architecture.

  • postgres: Both the standalone function and the method on the postgres.Migrator related to tenant schema creation have been renamed to MigrateTenantModels. This unified change better reflects their purpose and functionality, aligning with standard naming conventions and clarifying their intent within the driver module.

    Updated Standalone Function Signature:

    -func CreateSchemaForTenant(db *gorm.DB, schemaName string) error
    +func MigrateTenantModels(db *gorm.DB, schemaName string) error
    

    Updated Method Signature on postgres.Migrator:

    -func (m Migrator) CreateSchemaForTenant(tenant string) error
    +func (m Migrator) MigrateTenantModels(tenantID string) error
    

    Note:
    The underlying logic for both the function and method remains unchanged, with only the names being updated to provide clarity and consistency across the driver module.

  • postgres: The removal of the ResetSearchPath type and the ValidateTenantName function from the postgres/schema package significantly simplifies the driver architecture. This change aims to ensure consistent behavior across driver modules and promote better code organization and maintainability. It's now recommended to handle tenant name validation at the application level if necessary.

  • The relocation of TenantModel and TenantPKModel from the postgres driver to the github.com/bartventer/gorm-multitenancy/v8 package, and the renaming of the SchemaName field to ID in TenantPKModel, necessitate updates to import paths and model references across all projects using the gorm-multitenancy package.

    • Structs Relocation: Moved TenantModel and TenantPKModel from the postgres driver to github.com/bartventer/gorm-multitenancy/v8, making them accessible across all drivers and promoting code reuse.
    • Field Renaming: Renamed SchemaName field to ID in TenantPKModel for a more generic and consistent primary key representation, aligning with standard naming conventions.
    • Compatibility Update: Modified check constraints for the SchemaName (now ID) field to ensure compatibility with all supported database drivers.

    Updated import paths:

    -github.com/bartventer/gorm-multitenancy/postgres/v7.TenantModel
    +github.com/bartventer/gorm-multitenancy/v8.TenantModel
    
    -github.com/bartventer/gorm-multitenancy/postgres/v7.TenantPKModel
    +github.com/bartventer/gorm-multitenancy/v8.TenantPKModel
    
  • driver: Adjustments to the TenantTabler interface enhance its utility and consistency across the gorm-multitenancy package.

    • Moved: TenantTabler interface is now in github.com/bartventer/gorm-multitenancy/v8/pkg/driver, making it accessible to all drivers.
    • Renamed: IsTenantTable method to IsSharedTable to accurately describe shared models across tenants.

    Import paths update:

    -github.com/bartventer/gorm-multitenancy/postgres/v7.TenantTabler
    +github.com/bartventer/gorm-multitenancy/v8/pkg/driver.TenantTabler
    
  • pkg: The scopes package within the postgres driver has been moved to the pkg directory for better organization and consistency. Update your import paths accordingly to reflect this change.

    -github.com/bartventer/gorm-multitenancy/postgres/v7/scopes
    +github.com/bartventer/gorm-multitenancy/v8/pkg/scopes
    
  • drivers: The drivers directory has been removed from the project structure. All driver modules have been moved up one level higher to promote better organization and accessibility. For example, the github.com/bartventer/gorm-multitenancy/drivers/postgres directory is now located at github.com/bartventer/gorm-multitenancy/postgres.

  • context: This modification necessitates updates to context management practices across the board. Developers must now utilize the specific context keys provided by each middleware and driver, aligning with the decentralized approach to context management.

gorm-multitenancy - v7.0.1

Published by github-actions[bot] 4 months ago

7.0.1 (2024-06-21)

Bug Fixes

  • deps: Bump dependencies (977a3d3)
gorm-multitenancy - v7.0.0

Published by github-actions[bot] 4 months ago

7.0.0 (2024-06-20)

Bug Fixes

  • examples: Update import paths (04c7418)

Features

  • Convert packages into Go modules (ac07041)
  • Move TenantContext package to main Go module (4510b2d)
  • Move TenantTabler interface to drivers/postgres module (8b5c287)
  • Update import paths for major version 7 (3dcc88f)
  • drivers/postgres: Move scopes package to drivers/postgres module (e76d944)
  • drivers/postgres: Remove deprecated GetSchemaNameFromDb function (0d12bc5)

BREAKING CHANGES

- import "github.com/bartventer/gorm-multitenancy/v6/drivers/postgres"
+ import "github.com/bartventer/gorm-multitenancy/drivers/postgres/v7"

- import "github.com/bartventer/gorm-multitenancy/v6/middleware/echo"
+ import "github.com/bartventer/gorm-multitenancy/middleware/echo/v7"

- import "github.com/bartventer/gorm-multitenancy/v6/middleware/nethttp"
+ import "github.com/bartventer/gorm-multitenancy/middleware/nethttp/v7"

After updating the import paths, run go get -u for each new module.

  • drivers/postgres: The scopes package has been relocated to the drivers/postgres module. Please update your import paths:
- import "github.com/bartventer/gorm-multitenancy/v6/scopes"
+ import "github.com/bartventer/gorm-multitenancy/drivers/postgres/v7/scopes"
  • The TenantTabler interface has been moved to the drivers/postgres module.

  • The TenantContext package has been moved to the main Go module. Please update your import paths:

- import "github.com/bartventer/gorm-multitenancy/v6/tenantcontext"
  • drivers/postgres: The deprecated GetSchemaNameFromDb function has been removed from the drivers/postgres/schema package.

  • All import paths have been updated to reflect the new major version 7. Please run go get -u for each new module after updating the import paths.

gorm-multitenancy - v6.1.3

Published by github-actions[bot] 4 months ago

6.1.3 (2024-06-18)

Bug Fixes

  • deps: bump gorm.io/driver/postgres from 1.5.7 to 1.5.9 (40c7d18)
gorm-multitenancy - v6.1.2

Published by github-actions[bot] 5 months ago

6.1.2 (2024-06-02)

Bug Fixes

  • examples/all: Update models to use value receivers (1766db1)
gorm-multitenancy - v6.1.1

Published by github-actions[bot] 5 months ago

6.1.1 (2024-05-24)

Bug Fixes

  • scopes: Reduce memory allocations in WithTenantSchema (1e5dc1b)
gorm-multitenancy - v6.1.0

Published by github-actions[bot] 5 months ago

6.1.0 (2024-05-23)

Features

  • scopes: Update WithTenantSchema to support pointer to array/slice of structs (b0682b8)
gorm-multitenancy - v6.0.3

Published by github-actions[bot] 5 months ago

6.0.3 (2024-05-19)

Bug Fixes

  • drivers/postgres: Optimize mutex usage, update variable names and comments (8e84f84)
gorm-multitenancy - v6.0.2

Published by github-actions[bot] 5 months ago

6.0.2 (2024-05-14)

Bug Fixes

  • deps: Remove unnecessary dependencies (f0ecd47)
gorm-multitenancy - v6.0.1

Published by github-actions[bot] 5 months ago

6.0.1 (2024-05-12)

Bug Fixes

  • deps: Bump dependencies (33ea997)
gorm-multitenancy - v6.0.0

Published by github-actions[bot] 5 months ago

6.0.0 (2024-05-12)

Code Refactoring

  • drivers/postgres: Move and rename "schema/postgres" to "drivers/postgres/schema" (5893893)

Features

  • upgrade: Update gorm-multitenancy from v5 to v6 (fa5e24b)
  • Add TenantPKModel with SchemaName as primary key (c7213b3)

Performance Improvements

  • drivers/postgres: Improve performance of SetSearchPath benchmarks (c459c4d)
  • schema/postgres: Remove fmt.Sprintf call in SetSearchPath (49ec0b3)
  • scopes: Improve table name caching performance (33441b1)
  • scopes: Remove reflection dependency from WithTenantSchema (9c6240d)

BREAKING CHANGES

  • upgrade: All file references to github.com/bartventer/gorm-multitenancy have been updated from v5 to v6. This major version upgrade may introduce breaking changes that require updates in the code where this package is imported.
  • drivers/postgres: This commit moves the "schema/postgres" package to "drivers/postgres/schema". This change aligns the package location and name with its purpose of providing utilities for managing PostgreSQL schemas in a multi-tenant application. The relocation and renaming improve code organization and clarity. This is a breaking change and requires updates in the code where this package is imported.
gorm-multitenancy - v5.11.0

Published by github-actions[bot] 6 months ago

5.11.0 (2024-05-09)

Bug Fixes

  • deps: Bump dependencies (74e1af3)
  • middleware: Consolidate middleware into nethttp package (fba8e16)

Features

  • schema/postgres: Add ValidateTenantName function for validating tenant names (7118bf6)
gorm-multitenancy - v5.10.1

Published by github-actions[bot] 6 months ago

5.10.1 (2024-04-26)

Chores

  • deps: bump gorm.io/gorm from 1.25.9 to 1.25.10 (#11) (f0cb6b2)
gorm-multitenancy - v5.10.0

Published by github-actions[bot] 6 months ago

5.10.0 (2024-04-26)

Features

  • examples: Move echo and net/http examples from internal/examples to examples directory. (5afea8d)
Package Rankings
Top 6.48% on Proxy.golang.org
Badges
Extracted from project README
Mentioned in Awesome Go Go Reference Release Go Report Card codecov Tests License
Related Projects