diff --git a/internal/query/idp_login_policy_link_test.go b/internal/query/idp_login_policy_link_test.go index 265d1c94ca..e1349f770e 100644 --- a/internal/query/idp_login_policy_link_test.go +++ b/internal/query/idp_login_policy_link_test.go @@ -12,12 +12,12 @@ import ( ) var ( - loginPolicyIDPLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_login_policy_links2.idp_id,` + + loginPolicyIDPLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_login_policy_links3.idp_id,` + ` projections.idps2.name,` + ` projections.idps2.type,` + ` COUNT(*) OVER ()` + - ` FROM projections.idp_login_policy_links2` + - ` LEFT JOIN projections.idps2 ON projections.idp_login_policy_links2.idp_id = projections.idps2.id`) + ` FROM projections.idp_login_policy_links3` + + ` LEFT JOIN projections.idps2 ON projections.idp_login_policy_links3.idp_id = projections.idps2.id`) loginPolicyIDPLinksCols = []string{ "idp_id", "name", diff --git a/internal/query/login_policy_test.go b/internal/query/login_policy_test.go index c281d0cd6f..a6e333d123 100644 --- a/internal/query/login_policy_test.go +++ b/internal/query/login_policy_test.go @@ -50,14 +50,14 @@ func Test_LoginPolicyPrepares(t *testing.T) { ` projections.login_policies.mfa_init_skip_lifetime,`+ ` projections.login_policies.second_factor_check_lifetime,`+ ` projections.login_policies.multi_factor_check_lifetime,`+ - ` projections.idp_login_policy_links2.idp_id,`+ + ` projections.idp_login_policy_links3.idp_id,`+ ` projections.idps2.name,`+ ` projections.idps2.type`+ ` FROM projections.login_policies`+ - ` LEFT JOIN projections.idp_login_policy_links2 ON `+ - ` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+ + ` LEFT JOIN projections.idp_login_policy_links3 ON `+ + ` projections.login_policies.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+ ` LEFT JOIN projections.idps2 ON`+ - ` projections.idp_login_policy_links2.idp_id = projections.idps2.id`), + ` projections.idp_login_policy_links3.idp_id = projections.idps2.id`), nil, nil, ), @@ -95,14 +95,14 @@ func Test_LoginPolicyPrepares(t *testing.T) { ` projections.login_policies.mfa_init_skip_lifetime,`+ ` projections.login_policies.second_factor_check_lifetime,`+ ` projections.login_policies.multi_factor_check_lifetime,`+ - ` projections.idp_login_policy_links2.idp_id,`+ + ` projections.idp_login_policy_links3.idp_id,`+ ` projections.idps2.name,`+ ` projections.idps2.type`+ ` FROM projections.login_policies`+ - ` LEFT JOIN projections.idp_login_policy_links2 ON `+ - ` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+ + ` LEFT JOIN projections.idp_login_policy_links3 ON `+ + ` projections.login_policies.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+ ` LEFT JOIN projections.idps2 ON`+ - ` projections.idp_login_policy_links2.idp_id = projections.idps2.id`), + ` projections.idp_login_policy_links3.idp_id = projections.idps2.id`), []string{ "aggregate_id", "creation_date", @@ -210,14 +210,14 @@ func Test_LoginPolicyPrepares(t *testing.T) { ` projections.login_policies.mfa_init_skip_lifetime,`+ ` projections.login_policies.second_factor_check_lifetime,`+ ` projections.login_policies.multi_factor_check_lifetime,`+ - ` projections.idp_login_policy_links2.idp_id,`+ + ` projections.idp_login_policy_links3.idp_id,`+ ` projections.idps2.name,`+ ` projections.idps2.type`+ ` FROM projections.login_policies`+ - ` LEFT JOIN projections.idp_login_policy_links2 ON `+ - ` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+ + ` LEFT JOIN projections.idp_login_policy_links3 ON `+ + ` projections.login_policies.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+ ` LEFT JOIN projections.idps2 ON`+ - ` projections.idp_login_policy_links2.idp_id = projections.idps2.id`), + ` projections.idp_login_policy_links3.idp_id = projections.idps2.id`), sql.ErrConnDone, ), err: func(err error) (error, bool) { diff --git a/internal/query/projection/idp_login_policy_link.go b/internal/query/projection/idp_login_policy_link.go index 9d0dfce299..8518c24ffe 100644 --- a/internal/query/projection/idp_login_policy_link.go +++ b/internal/query/projection/idp_login_policy_link.go @@ -14,7 +14,7 @@ import ( ) const ( - IDPLoginPolicyLinkTable = "projections.idp_login_policy_links2" + IDPLoginPolicyLinkTable = "projections.idp_login_policy_links3" IDPLoginPolicyLinkIDPIDCol = "idp_id" IDPLoginPolicyLinkAggregateIDCol = "aggregate_id" @@ -43,7 +43,7 @@ func newIDPLoginPolicyLinkProjection(ctx context.Context, config crdb.StatementH crdb.NewColumn(IDPLoginPolicyLinkSequenceCol, crdb.ColumnTypeInt64), crdb.NewColumn(IDPLoginPolicyLinkResourceOwnerCol, crdb.ColumnTypeText), crdb.NewColumn(IDPLoginPolicyLinkInstanceIDCol, crdb.ColumnTypeText), - crdb.NewColumn(IDPLoginPolicyLinkProviderTypeCol, crdb.ColumnTypeText), + crdb.NewColumn(IDPLoginPolicyLinkProviderTypeCol, crdb.ColumnTypeEnum), }, crdb.NewPrimaryKey(IDPLoginPolicyLinkInstanceIDCol, IDPLoginPolicyLinkAggregateIDCol, IDPLoginPolicyLinkIDPIDCol), crdb.WithIndex(crdb.NewIndex("link_ro_idx", []string{IDPLoginPolicyLinkResourceOwnerCol})), diff --git a/internal/query/projection/idp_login_policy_link_test.go b/internal/query/projection/idp_login_policy_link_test.go index d668dccecb..ae2e612f2e 100644 --- a/internal/query/projection/idp_login_policy_link_test.go +++ b/internal/query/projection/idp_login_policy_link_test.go @@ -43,7 +43,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.idp_login_policy_links2 (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", + expectedStmt: "INSERT INTO projections.idp_login_policy_links3 (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", expectedArgs: []interface{}{ "idp-config-id", "agg-id", @@ -80,7 +80,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedArgs: []interface{}{ "idp-config-id", "agg-id", @@ -111,7 +111,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedArgs: []interface{}{ "idp-config-id", "agg-id", @@ -142,7 +142,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.idp_login_policy_links2 (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", + expectedStmt: "INSERT INTO projections.idp_login_policy_links3 (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", expectedArgs: []interface{}{ "idp-config-id", "agg-id", @@ -179,7 +179,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedArgs: []interface{}{ "idp-config-id", "agg-id", @@ -210,7 +210,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedArgs: []interface{}{ "idp-config-id", "agg-id", @@ -238,7 +238,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (resource_owner = $1)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (resource_owner = $1)", expectedArgs: []interface{}{ "agg-id", }, @@ -267,7 +267,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (resource_owner = $2)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2)", expectedArgs: []interface{}{ "idp-config-id", "ro-id", @@ -297,7 +297,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (resource_owner = $2)", + expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2)", expectedArgs: []interface{}{ "idp-config-id", "ro-id",