Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DISCRIMINATOR mode #2916

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class H2DiscriminatorMultitenancyRecordSpec extends Specification implements H2T
setup:
EmbeddedServer embeddedServer = ApplicationContext.run(EmbeddedServer, getExtraProperties() + getProperties() + [
'spec.name' : 'discriminator-multitenancy-record',
'micronaut.data.multi-tenancy.mode' : 'DISCRIMINATOR',
'micronaut.multitenancy.tenantresolver.httpheader.enabled': 'true',
'datasource.default.schema-generate' : 'create-drop'
], Environment.TEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,5 @@ public enum MultiTenancyMode {
/**
* The same database, but different schemas are used to store each tenants data.
*/
SCHEMA,
/**
* The same database is used with a discriminator used to partition and isolate data.
*/
DISCRIMINATOR
SCHEMA
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ abstract class AbstractDiscriminatorMultitenancySpec extends Specification {
setup:
EmbeddedServer embeddedServer = ApplicationContext.run(EmbeddedServer, getExtraProperties() + getProperties() + [
'spec.name' : 'discriminator-multitenancy',
'micronaut.data.multi-tenancy.mode' : 'DISCRIMINATOR',
'micronaut.multitenancy.tenantresolver.httpheader.enabled': 'true',
'datasource.default.schema-generate' : 'create-drop'
], Environment.TEST)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
micronaut:
data:
multi-tenancy:
mode: DISCRIMINATOR
multitenancy:
tenantresolver:
httpheader:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
micronaut:
data:
multi-tenancy:
mode: DISCRIMINATOR
multitenancy:
tenantresolver:
httpheader:
enabled: true

datasources:
default:
url: jdbc:h2:mem:db
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
micronaut:
data:
multi-tenancy:
mode: DISCRIMINATOR
multitenancy:
tenantresolver:
httpheader:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
micronaut:
data:
multi-tenancy:
mode: DISCRIMINATOR
multitenancy:
tenantresolver:
httpheader:
Expand Down
17 changes: 1 addition & 16 deletions src/main/docs/guide/multitenancy.adoc
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
Micronaut Data supports multi-tenancy to allow the use of multiple databases or schemas by a single micronaut application.

.Supported Multitenancy Modes

|===
|Multitenancy Mode | Description

|DATASOURCE
|A separate database with a separate connection pool is used to store each tenants data. Internally different repository operations / transaction manager instance will be used for each tenant.

|SCHEMA
|The same database, but different schemas are used to store each tenants data. Only supported by JDBC/R2DBC/MongoDB (collections)

|DISCRIMINATOR
|A single database/schema stores all tenants' data, but a discriminator column separates the data.
|===
You can use Micronaut Data to partition your data based on the current tenant. It leverages https://micronaut-projects.github.io/micronaut-multitenancy/snapshot/guide/[Micronaut Multi-tenancy] for tenant resolution.
10 changes: 1 addition & 9 deletions src/main/docs/guide/shared/multitenancy/discriminatormode.adoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
The DISCRIMINATOR mode uses a single entity's property to store the tenant id.

.Example of the configuration with one data source
[configuration]
----
include::doc-examples/jdbc-multitenancy-discriminator-example-java/src/main/resources/application.yml[]
----

The entity with multitenancy enabled requires a tenant property to be annotated with api:data.annotation.TenantId[]:
When using discriminator column multitenancy, the entity with multitenancy enabled requires a property to be annotated with api:data.annotation.TenantId[]:

[source,java]
----
Expand Down
16 changes: 16 additions & 0 deletions src/main/docs/guide/shared/multitenancy/multitenancymodes.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
In addition to discriminator column multitenancy, Micronaut Data supports multi-tenancy to allow the use of multiple databases or schemas by a single micronaut application.

You can set the multitenancy mode by setting the property `micronaut.data.multi-tenancy.mode`.

.Supported Multitenancy Modes

|===
|Multitenancy Mode | Description

|DATASOURCE
|A separate database with a separate connection pool is used to store each tenants data. Internally different repository operations / transaction manager instance will be used for each tenant.

|SCHEMA
|The same database, but different schemas are used to store each tenants data. Only supported by JDBC/R2DBC/MongoDB (collections)

|===
1 change: 1 addition & 0 deletions src/main/docs/guide/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ shared:
multitenancy:
title: Multi-tenancy
discriminatormode: Discriminator Mode
multitenancymodes: Multitenancy modes
datasourcemode: DataSource Mode
schemamode: Schema Mode
hibernate:
Expand Down