mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 01:18:51 +00:00
fix(features): increment version to deal with removed event types (#11402)
# Which Problems Are Solved User with older instances, created at version 3.3.3 or earlier may have been affected with feature flags no longer applying. Older version of Zitadel had a bug in console where toggling a single feature would apply a state to all features, creating around 12 events each request. Then 4 feature flags and their event types were removed in v4, meaning that the `offset` value in the projection's current state could be wrong by 4 if the instance was affected by the above bug. # How the Problems Are Solved Increment the feature projection versions, so that the tables get recomputed and the current states entries becomes accurate again. # Additional Changes - none # Additional Context - Original bug: https://github.com/zitadel/zitadel/issues/10459 - Reported through support
This commit is contained in:
@@ -6,14 +6,14 @@ with domain as (
|
|||||||
), instance_features as (
|
), instance_features as (
|
||||||
select i.*
|
select i.*
|
||||||
from domain d
|
from domain d
|
||||||
join projections.instance_features2 i on d.instance_id = i.instance_id
|
join projections.instance_features3 i on d.instance_id = i.instance_id
|
||||||
), features as (
|
), features as (
|
||||||
select instance_id, json_object_agg(
|
select instance_id, json_object_agg(
|
||||||
coalesce(i.key, s.key),
|
coalesce(i.key, s.key),
|
||||||
coalesce(i.value, s.value)
|
coalesce(i.value, s.value)
|
||||||
) features
|
) features
|
||||||
from domain d
|
from domain d
|
||||||
cross join projections.system_features s
|
cross join projections.system_features2 s
|
||||||
full outer join instance_features i using (instance_id, key)
|
full outer join instance_features i using (instance_id, key)
|
||||||
group by instance_id
|
group by instance_id
|
||||||
), external_domains as (
|
), external_domains as (
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ with features as (
|
|||||||
coalesce(i.value, s.value)
|
coalesce(i.value, s.value)
|
||||||
) features
|
) features
|
||||||
from (select $1::text instance_id) x
|
from (select $1::text instance_id) x
|
||||||
cross join projections.system_features s
|
cross join projections.system_features2 s
|
||||||
full outer join projections.instance_features2 i using (key, instance_id)
|
full outer join projections.instance_features3 i using (key, instance_id)
|
||||||
group by instance_id
|
group by instance_id
|
||||||
), external_domains as (
|
), external_domains as (
|
||||||
select instance_id, array_agg(domain) as domains
|
select instance_id, array_agg(domain) as domains
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
InstanceFeatureTable = "projections.instance_features2"
|
InstanceFeatureTable = "projections.instance_features3"
|
||||||
|
|
||||||
InstanceFeatureInstanceIDCol = "instance_id"
|
InstanceFeatureInstanceIDCol = "instance_id"
|
||||||
InstanceFeatureKeyCol = "key"
|
InstanceFeatureKeyCol = "key"
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func TestInstanceFeaturesProjection_reduces(t *testing.T) {
|
|||||||
executer: &testExecuter{
|
executer: &testExecuter{
|
||||||
executions: []execution{
|
executions: []execution{
|
||||||
{
|
{
|
||||||
expectedStmt: "INSERT INTO projections.instance_features2 (instance_id, key, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (instance_id, key) DO UPDATE SET (creation_date, change_date, sequence, value) = (projections.instance_features2.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
expectedStmt: "INSERT INTO projections.instance_features3 (instance_id, key, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (instance_id, key) DO UPDATE SET (creation_date, change_date, sequence, value) = (projections.instance_features3.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
||||||
expectedArgs: []interface{}{
|
expectedArgs: []interface{}{
|
||||||
"agg-id",
|
"agg-id",
|
||||||
"user_schema",
|
"user_schema",
|
||||||
@@ -69,7 +69,7 @@ func TestInstanceFeaturesProjection_reduces(t *testing.T) {
|
|||||||
executer: &testExecuter{
|
executer: &testExecuter{
|
||||||
executions: []execution{
|
executions: []execution{
|
||||||
{
|
{
|
||||||
expectedStmt: "INSERT INTO projections.instance_features2 (instance_id, key, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (instance_id, key) DO UPDATE SET (creation_date, change_date, sequence, value) = (projections.instance_features2.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
expectedStmt: "INSERT INTO projections.instance_features3 (instance_id, key, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (instance_id, key) DO UPDATE SET (creation_date, change_date, sequence, value) = (projections.instance_features3.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
||||||
expectedArgs: []interface{}{
|
expectedArgs: []interface{}{
|
||||||
"instance-id",
|
"instance-id",
|
||||||
"login_default_org",
|
"login_default_org",
|
||||||
@@ -100,7 +100,7 @@ func TestInstanceFeaturesProjection_reduces(t *testing.T) {
|
|||||||
executer: &testExecuter{
|
executer: &testExecuter{
|
||||||
executions: []execution{
|
executions: []execution{
|
||||||
{
|
{
|
||||||
expectedStmt: "DELETE FROM projections.instance_features2 WHERE (instance_id = $1)",
|
expectedStmt: "DELETE FROM projections.instance_features3 WHERE (instance_id = $1)",
|
||||||
expectedArgs: []interface{}{
|
expectedArgs: []interface{}{
|
||||||
"agg-id",
|
"agg-id",
|
||||||
},
|
},
|
||||||
@@ -126,7 +126,7 @@ func TestInstanceFeaturesProjection_reduces(t *testing.T) {
|
|||||||
executer: &testExecuter{
|
executer: &testExecuter{
|
||||||
executions: []execution{
|
executions: []execution{
|
||||||
{
|
{
|
||||||
expectedStmt: "DELETE FROM projections.instance_features2 WHERE (instance_id = $1)",
|
expectedStmt: "DELETE FROM projections.instance_features3 WHERE (instance_id = $1)",
|
||||||
expectedArgs: []interface{}{
|
expectedArgs: []interface{}{
|
||||||
"agg-id",
|
"agg-id",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SystemFeatureTable = "projections.system_features"
|
SystemFeatureTable = "projections.system_features2"
|
||||||
|
|
||||||
SystemFeatureKeyCol = "key"
|
SystemFeatureKeyCol = "key"
|
||||||
SystemFeatureCreationDateCol = "creation_date"
|
SystemFeatureCreationDateCol = "creation_date"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func TestSystemFeaturesProjection_reduces(t *testing.T) {
|
|||||||
executer: &testExecuter{
|
executer: &testExecuter{
|
||||||
executions: []execution{
|
executions: []execution{
|
||||||
{
|
{
|
||||||
expectedStmt: "INSERT INTO projections.system_features (key, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (key) DO UPDATE SET (creation_date, change_date, sequence, value) = (projections.system_features.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
expectedStmt: "INSERT INTO projections.system_features2 (key, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (key) DO UPDATE SET (creation_date, change_date, sequence, value) = (projections.system_features2.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
||||||
expectedArgs: []interface{}{
|
expectedArgs: []interface{}{
|
||||||
"user_schema",
|
"user_schema",
|
||||||
anyArg{},
|
anyArg{},
|
||||||
@@ -66,7 +66,7 @@ func TestSystemFeaturesProjection_reduces(t *testing.T) {
|
|||||||
executer: &testExecuter{
|
executer: &testExecuter{
|
||||||
executions: []execution{
|
executions: []execution{
|
||||||
{
|
{
|
||||||
expectedStmt: "DELETE FROM projections.system_features WHERE (key IS NOT NULL)",
|
expectedStmt: "DELETE FROM projections.system_features2 WHERE (key IS NOT NULL)",
|
||||||
expectedArgs: []interface{}{},
|
expectedArgs: []interface{}{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user