Skip to content

Latest commit

 

History

114 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Foundation Tenancy 📋

Shared tenancy components for IQKV microservices, including tenant context management, MyBatis schema interception, and Liquibase migration runner.

Quick Links

Key Components

TenantContext

ThreadLocal holder for current tenant key, with type-safe tenant key management.

// Set current tenant
TenantContext.setCurrentTenant("tenant123");

// Get current tenant
String tenant = TenantContext.getCurrentTenant();

// Clear (must call to prevent memory leaks)
TenantContext.clear();

MyBatisSchemaInterceptor

MyBatis Interceptor that automatically sets PostgreSQL search_path to the tenant schema (t_<tenantKey>, public) for each database operation when tenant context is active.

TenantLiquibaseRunner

Spring Boot ApplicationRunner that executes tenant-aware Liquibase migrations on startup, including:

  • System schema migrations (to public)
  • Tenant schema migrations (to t_<tenantKey>) for each pre-provisioned tenant (if configured via iqkv.liquibase.bootstrap-tenants)

LiquibaseConfigurationProperties

Spring Boot configuration properties for tenancy-related Liquibase settings:

iqkv:
    liquibase:
        system-change-log: db/changelog/system/db.changelog-master.xml
        tenant-change-log: db/changelog/tenant/master.xml
        contexts: dev,prod
        bootstrap-tenants:
            - tenant1
            - tenant2
        tenant-runner-enabled: true # default is true

Usage

Maven Dependency

<dependency>
  <groupId>com.iqkv</groupId>
  <artifactId>foundation-tenancy</artifactId>
  <version>0.24.0-SNAPSHOT</version>
</dependency>

Spring Boot Auto-Configuration

When added as a dependency to a Spring Boot project, TenantLiquibaseRunner and LiquibaseConfigurationProperties are auto-configured if Liquibase is available on the classpath.

Development

# Build and install to local Maven repository
./mvnw clean install -Dcheckstyle.skip=true

About

Shared tenancy components for IQKV microservices.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages