feat: Feature flag for relational tables (#10599)

# Which Problems Are Solved

This PR introduces a new feature flag `EnableRelationalTables` that will
be used in following implementations to decide whether Zitadel should
use the relational model or the event sourcing one.

# TODO

  - [x] Implement flag at system level
- [x] Display the flag on console:
https://github.com/zitadel/zitadel/pull/10615

# How the Problems Are Solved

  - Implement loading the flag from config
- Add persistence of the flag through gRPC endpoint
(SetInstanceFeatures)
- Implement reading of the flag through gRPC endpoint
(GetInstanceFeatures)

# Additional Changes

Some minor refactoring to remove un-needed generics annotations

# Additional Context

- Closes #10574

---------

Co-authored-by: Silvan <[email protected]>
This commit is contained in:
Marco A.
2025-09-02 09:48:46 +00:00
committed by GitHub
co-authored by Silvan
parent e3dff2482e
commit 75a67be669
46 changed files with 669 additions and 91 deletions
@@ -76,7 +76,8 @@ func TestServer_SetSystemFeatures(t *testing.T) {
args: args{
ctx: SystemCTX,
req: &feature.SetSystemFeaturesRequest{
LoginDefaultOrg: gu.Ptr(true),
LoginDefaultOrg: gu.Ptr(true),
EnableRelationalTables: gu.Ptr(true),
},
},
want: &feature.SetSystemFeaturesResponse{
@@ -170,8 +171,9 @@ func TestServer_GetSystemFeatures(t *testing.T) {
name: "some features",
prepare: func(t *testing.T) {
_, err := Client.SetSystemFeatures(SystemCTX, &feature.SetSystemFeaturesRequest{
LoginDefaultOrg: gu.Ptr(true),
UserSchema: gu.Ptr(false),
LoginDefaultOrg: gu.Ptr(true),
UserSchema: gu.Ptr(false),
EnableRelationalTables: gu.Ptr(true),
})
require.NoError(t, err)
},
@@ -188,6 +190,10 @@ func TestServer_GetSystemFeatures(t *testing.T) {
Enabled: false,
Source: feature.Source_SOURCE_SYSTEM,
},
EnableRelationalTables: &feature.FeatureFlag{
Enabled: true,
Source: feature.Source_SOURCE_SYSTEM,
},
},
},
}
@@ -209,6 +215,7 @@ func TestServer_GetSystemFeatures(t *testing.T) {
require.NoError(t, err)
assertFeatureFlag(t, tt.want.LoginDefaultOrg, got.LoginDefaultOrg)
assertFeatureFlag(t, tt.want.UserSchema, got.UserSchema)
assertFeatureFlag(t, tt.want.EnableRelationalTables, got.EnableRelationalTables)
})
}
}
@@ -247,7 +254,8 @@ func TestServer_SetInstanceFeatures(t *testing.T) {
args: args{
ctx: IamCTX,
req: &feature.SetInstanceFeaturesRequest{
LoginDefaultOrg: gu.Ptr(true),
LoginDefaultOrg: gu.Ptr(true),
EnableRelationalTables: gu.Ptr(true),
},
},
want: &feature.SetInstanceFeaturesResponse{
@@ -363,14 +371,19 @@ func TestServer_GetInstanceFeatures(t *testing.T) {
Enabled: false,
Source: feature.Source_SOURCE_UNSPECIFIED,
},
EnableRelationalTables: &feature.FeatureFlag{
Enabled: false,
Source: feature.Source_SOURCE_UNSPECIFIED,
},
},
},
{
name: "some features, no inheritance",
prepare: func(t *testing.T) {
_, err := Client.SetInstanceFeatures(IamCTX, &feature.SetInstanceFeaturesRequest{
LoginDefaultOrg: gu.Ptr(true),
UserSchema: gu.Ptr(true),
LoginDefaultOrg: gu.Ptr(true),
UserSchema: gu.Ptr(true),
EnableRelationalTables: gu.Ptr(true),
})
require.NoError(t, err)
},
@@ -387,6 +400,10 @@ func TestServer_GetInstanceFeatures(t *testing.T) {
Enabled: true,
Source: feature.Source_SOURCE_INSTANCE,
},
EnableRelationalTables: &feature.FeatureFlag{
Enabled: true,
Source: feature.Source_SOURCE_INSTANCE,
},
},
},
{
@@ -412,6 +429,10 @@ func TestServer_GetInstanceFeatures(t *testing.T) {
Enabled: false,
Source: feature.Source_SOURCE_UNSPECIFIED,
},
EnableRelationalTables: &feature.FeatureFlag{
Enabled: false,
Source: feature.Source_SOURCE_UNSPECIFIED,
},
},
},
}
@@ -433,6 +454,7 @@ func TestServer_GetInstanceFeatures(t *testing.T) {
require.NoError(t, err)
assertFeatureFlag(t, tt.want.LoginDefaultOrg, got.LoginDefaultOrg)
assertFeatureFlag(t, tt.want.UserSchema, got.UserSchema)
assertFeatureFlag(t, tt.want.EnableRelationalTables, got.EnableRelationalTables)
})
}
}