Skip to content

Releases: bartventer/gorm-multitenancy

v8.0.0

05 Jul 12:28
Compare
Choose a tag to compare

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.

v7.0.1

21 Jun 10:34
890cdea
Compare
Choose a tag to compare

7.0.1 (2024-06-21)

Bug Fixes

  • deps: Bump dependencies (977a3d3)

v7.0.0

20 Jun 15:51
9fcc197
Compare
Choose a tag to compare

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.

v6.1.3

18 Jun 12:48
Compare
Choose a tag to compare

6.1.3 (2024-06-18)

Bug Fixes

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

v6.1.2

02 Jun 21:23
Compare
Choose a tag to compare

6.1.2 (2024-06-02)

Bug Fixes

  • examples/all: Update models to use value receivers (1766db1)

v6.1.1

24 May 05:03
Compare
Choose a tag to compare

6.1.1 (2024-05-24)

Bug Fixes

  • scopes: Reduce memory allocations in WithTenantSchema (1e5dc1b)

v6.1.0

23 May 15:10
Compare
Choose a tag to compare

6.1.0 (2024-05-23)

Features

  • scopes: Update WithTenantSchema to support pointer to array/slice of structs (b0682b8)

v6.0.3

19 May 12:05
Compare
Choose a tag to compare

6.0.3 (2024-05-19)

Bug Fixes

  • drivers/postgres: Optimize mutex usage, update variable names and comments (8e84f84)

v6.0.2

16 May 20:18
Compare
Choose a tag to compare

6.0.2 (2024-05-14)

Bug Fixes

  • deps: Remove unnecessary dependencies (f0ecd47)

v6.0.1

12 May 18:21
Compare
Choose a tag to compare

6.0.1 (2024-05-12)

Bug Fixes

  • deps: Bump dependencies (33ea997)