Releases: bartventer/gorm-multitenancy
v8.0.0
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
- Update to Version 8 (8ad3e8b)
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 thepostgres
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 toMigrateTenantModels
. 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 theValidateTenantName
function from thepostgres/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
andTenantPKModel
from thepostgres
driver to thegithub.com/bartventer/gorm-multitenancy/v8
package, and the renaming of theSchemaName
field toID
inTenantPKModel
, necessitate updates to import paths and model references across all projects using thegorm-multitenancy
package.- Structs Relocation: Moved
TenantModel
andTenantPKModel
from thepostgres
driver togithub.com/bartventer/gorm-multitenancy/v8
, making them accessible across all drivers and promoting code reuse. - Field Renaming: Renamed
SchemaName
field toID
inTenantPKModel
for a more generic and consistent primary key representation, aligning with standard naming conventions. - Compatibility Update: Modified check constraints for the
SchemaName
(nowID
) 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
- Structs Relocation: Moved
-
driver: Adjustments to the
TenantTabler
interface enhance its utility and consistency across thegorm-multitenancy
package.- Moved:
TenantTabler
interface is now ingithub.com/bartventer/gorm-multitenancy/v8/pkg/driver
, making it accessible to all drivers. - Renamed:
IsTenantTable
method toIsSharedTable
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
- Moved:
-
pkg: The
scopes
package within thepostgres
driver has been moved to thepkg
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, thegithub.com/bartventer/gorm-multitenancy/drivers/postgres
directory is now located atgithub.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
v7.0.0
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 todrivers/postgres
module (8b5c287) - Update import paths for major version 7 (3dcc88f)
- drivers/postgres: Move
scopes
package todrivers/postgres
module (e76d944) - drivers/postgres: Remove deprecated
GetSchemaNameFromDb
function (0d12bc5)
BREAKING CHANGES
- To improve dependency isolation, we've converted the following packages into their own Go modules:
drivers/postgres
,middleware/echo
,middleware/nethttp
. Please update your import paths:
- 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 thedrivers/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 thedrivers/postgres
module. -
The
TenantContext
package has been moved to themain 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 thedrivers/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.