From 22204260f10072da53055cd375e3303e25e15e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Tue, 14 Nov 2023 14:51:55 +0200 Subject: [PATCH] drop owner_removed column on user projections --- internal/api/grpc/auth/email.go | 2 +- internal/api/grpc/auth/phone.go | 2 +- internal/api/grpc/auth/profile.go | 2 +- internal/api/grpc/management/user.go | 8 +- internal/api/grpc/user/v2/user.go | 2 +- .../eventstore/token_verifier.go | 2 +- internal/query/embed/userinfo_by_id.sql | 6 +- internal/query/iam_member_test.go | 26 +- internal/query/org_member_test.go | 32 +-- internal/query/project_grant_member_test.go | 32 +-- internal/query/project_member_test.go | 32 +-- internal/query/projection/user.go | 5 +- internal/query/projection/user_test.go | 166 +++++------ internal/query/sessions_test.go | 16 +- internal/query/user.go | 25 +- internal/query/user_auth_method.go | 10 +- internal/query/user_auth_method_test.go | 22 +- internal/query/user_grant_test.go | 40 +-- internal/query/user_test.go | 260 +++++++++--------- 19 files changed, 332 insertions(+), 358 deletions(-) diff --git a/internal/api/grpc/auth/email.go b/internal/api/grpc/auth/email.go index 7c336ca1fc..3e4f636c7f 100644 --- a/internal/api/grpc/auth/email.go +++ b/internal/api/grpc/auth/email.go @@ -11,7 +11,7 @@ import ( ) func (s *Server) GetMyEmail(ctx context.Context, _ *auth_pb.GetMyEmailRequest) (*auth_pb.GetMyEmailResponse, error) { - email, err := s.query.GetHumanEmail(ctx, authz.GetCtxData(ctx).UserID, false) + email, err := s.query.GetHumanEmail(ctx, authz.GetCtxData(ctx).UserID) if err != nil { return nil, err } diff --git a/internal/api/grpc/auth/phone.go b/internal/api/grpc/auth/phone.go index 5d5b722afc..6134295f3c 100644 --- a/internal/api/grpc/auth/phone.go +++ b/internal/api/grpc/auth/phone.go @@ -11,7 +11,7 @@ import ( ) func (s *Server) GetMyPhone(ctx context.Context, _ *auth_pb.GetMyPhoneRequest) (*auth_pb.GetMyPhoneResponse, error) { - phone, err := s.query.GetHumanPhone(ctx, authz.GetCtxData(ctx).UserID, false) + phone, err := s.query.GetHumanPhone(ctx, authz.GetCtxData(ctx).UserID) if err != nil { return nil, err } diff --git a/internal/api/grpc/auth/profile.go b/internal/api/grpc/auth/profile.go index 9d5d02c2ca..50f973c616 100644 --- a/internal/api/grpc/auth/profile.go +++ b/internal/api/grpc/auth/profile.go @@ -10,7 +10,7 @@ import ( ) func (s *Server) GetMyProfile(ctx context.Context, req *auth_pb.GetMyProfileRequest) (*auth_pb.GetMyProfileResponse, error) { - profile, err := s.query.GetHumanProfile(ctx, authz.GetCtxData(ctx).UserID, false) + profile, err := s.query.GetHumanProfile(ctx, authz.GetCtxData(ctx).UserID) if err != nil { return nil, err } diff --git a/internal/api/grpc/management/user.go b/internal/api/grpc/management/user.go index 6c9da0af32..0f6b937877 100644 --- a/internal/api/grpc/management/user.go +++ b/internal/api/grpc/management/user.go @@ -128,7 +128,7 @@ func (s *Server) IsUserUnique(ctx context.Context, req *mgmt_pb.IsUserUniqueRequ if !policy.UserLoginMustBeDomain { orgID = "" } - unique, err := s.query.IsUserUnique(ctx, req.UserName, req.Email, orgID, false) + unique, err := s.query.IsUserUnique(ctx, req.UserName, req.Email, orgID) if err != nil { return nil, err } @@ -406,7 +406,7 @@ func (s *Server) GetHumanProfile(ctx context.Context, req *mgmt_pb.GetHumanProfi if err != nil { return nil, err } - profile, err := s.query.GetHumanProfile(ctx, req.UserId, false, owner) + profile, err := s.query.GetHumanProfile(ctx, req.UserId, owner) if err != nil { return nil, err } @@ -440,7 +440,7 @@ func (s *Server) GetHumanEmail(ctx context.Context, req *mgmt_pb.GetHumanEmailRe if err != nil { return nil, err } - email, err := s.query.GetHumanEmail(ctx, req.UserId, false, owner) + email, err := s.query.GetHumanEmail(ctx, req.UserId, owner) if err != nil { return nil, err } @@ -506,7 +506,7 @@ func (s *Server) GetHumanPhone(ctx context.Context, req *mgmt_pb.GetHumanPhoneRe if err != nil { return nil, err } - phone, err := s.query.GetHumanPhone(ctx, req.UserId, false, owner) + phone, err := s.query.GetHumanPhone(ctx, req.UserId, owner) if err != nil { return nil, err } diff --git a/internal/api/grpc/user/v2/user.go b/internal/api/grpc/user/v2/user.go index 5ee56f2b68..4301bc097d 100644 --- a/internal/api/grpc/user/v2/user.go +++ b/internal/api/grpc/user/v2/user.go @@ -360,7 +360,7 @@ func (s *Server) checkIntentToken(token string, intentID string) error { } func (s *Server) ListAuthenticationMethodTypes(ctx context.Context, req *user.ListAuthenticationMethodTypesRequest) (*user.ListAuthenticationMethodTypesResponse, error) { - authMethods, err := s.query.ListActiveUserAuthMethodTypes(ctx, req.GetUserId(), false) + authMethods, err := s.query.ListActiveUserAuthMethodTypes(ctx, req.GetUserId()) if err != nil { return nil, err } diff --git a/internal/authz/repository/eventsourcing/eventstore/token_verifier.go b/internal/authz/repository/eventsourcing/eventstore/token_verifier.go index bcc4cfd34f..823a6da4db 100644 --- a/internal/authz/repository/eventsourcing/eventstore/token_verifier.go +++ b/internal/authz/repository/eventsourcing/eventstore/token_verifier.go @@ -171,7 +171,7 @@ func (repo *TokenVerifierRepo) checkAuthentication(ctx context.Context, authMeth if domain.HasMFA(authMethods) { return nil } - availableAuthMethods, forceMFA, forceMFALocalOnly, err := repo.Query.ListUserAuthMethodTypesRequired(setCallerCtx(ctx, userID), userID, false) + availableAuthMethods, forceMFA, forceMFALocalOnly, err := repo.Query.ListUserAuthMethodTypesRequired(setCallerCtx(ctx, userID), userID) if err != nil { return err } diff --git a/internal/query/embed/userinfo_by_id.sql b/internal/query/embed/userinfo_by_id.sql index 3b02a6531c..9056e2fe6d 100644 --- a/internal/query/embed/userinfo_by_id.sql +++ b/internal/query/embed/userinfo_by_id.sql @@ -1,13 +1,13 @@ with usr as ( select id, creation_date, change_date, sequence, state, resource_owner, username - from projections.users8 u + from projections.users9 u where id = $1 and instance_id = $2 ), human as ( select $1 as user_id, row_to_json(r) as human from ( select first_name, last_name, nick_name, display_name, avatar_key, email, is_email_verified, phone, is_phone_verified - from projections.users8_humans + from projections.users9_humans where user_id = $1 and instance_id = $2 ) r @@ -15,7 +15,7 @@ human as ( machine as ( select $1 as user_id, row_to_json(r) as machine from ( select name, description - from projections.users8_machines + from projections.users9_machines where user_id = $1 and instance_id = $2 ) r diff --git a/internal/query/iam_member_test.go b/internal/query/iam_member_test.go index 68e1f90f73..d6a178481a 100644 --- a/internal/query/iam_member_test.go +++ b/internal/query/iam_member_test.go @@ -21,21 +21,21 @@ var ( ", members.user_id" + ", members.roles" + ", projections.login_names2.login_name" + - ", projections.users8_humans.email" + - ", projections.users8_humans.first_name" + - ", projections.users8_humans.last_name" + - ", projections.users8_humans.display_name" + - ", projections.users8_machines.name" + - ", projections.users8_humans.avatar_key" + - ", projections.users8.type" + + ", projections.users9_humans.email" + + ", projections.users9_humans.first_name" + + ", projections.users9_humans.last_name" + + ", projections.users9_humans.display_name" + + ", projections.users9_machines.name" + + ", projections.users9_humans.avatar_key" + + ", projections.users9.type" + ", COUNT(*) OVER () " + "FROM projections.instance_members3 AS members " + - "LEFT JOIN projections.users8_humans " + - "ON members.user_id = projections.users8_humans.user_id AND members.instance_id = projections.users8_humans.instance_id " + - "LEFT JOIN projections.users8_machines " + - "ON members.user_id = projections.users8_machines.user_id AND members.instance_id = projections.users8_machines.instance_id " + - "LEFT JOIN projections.users8 " + - "ON members.user_id = projections.users8.id AND members.instance_id = projections.users8.instance_id " + + "LEFT JOIN projections.users9_humans " + + "ON members.user_id = projections.users9_humans.user_id AND members.instance_id = projections.users9_humans.instance_id " + + "LEFT JOIN projections.users9_machines " + + "ON members.user_id = projections.users9_machines.user_id AND members.instance_id = projections.users9_machines.instance_id " + + "LEFT JOIN projections.users9 " + + "ON members.user_id = projections.users9.id AND members.instance_id = projections.users9.instance_id " + "LEFT JOIN projections.login_names2 " + "ON members.user_id = projections.login_names2.user_id AND members.instance_id = projections.login_names2.instance_id " + "AS OF SYSTEM TIME '-1 ms' " + diff --git a/internal/query/org_member_test.go b/internal/query/org_member_test.go index ee599b0e57..5eb6d2d58f 100644 --- a/internal/query/org_member_test.go +++ b/internal/query/org_member_test.go @@ -21,24 +21,24 @@ var ( ", members.user_id" + ", members.roles" + ", projections.login_names2.login_name" + - ", projections.users8_humans.email" + - ", projections.users8_humans.first_name" + - ", projections.users8_humans.last_name" + - ", projections.users8_humans.display_name" + - ", projections.users8_machines.name" + - ", projections.users8_humans.avatar_key" + - ", projections.users8.type" + + ", projections.users9_humans.email" + + ", projections.users9_humans.first_name" + + ", projections.users9_humans.last_name" + + ", projections.users9_humans.display_name" + + ", projections.users9_machines.name" + + ", projections.users9_humans.avatar_key" + + ", projections.users9.type" + ", COUNT(*) OVER () " + "FROM projections.org_members3 AS members " + - "LEFT JOIN projections.users8_humans " + - "ON members.user_id = projections.users8_humans.user_id " + - "AND members.instance_id = projections.users8_humans.instance_id " + - "LEFT JOIN projections.users8_machines " + - "ON members.user_id = projections.users8_machines.user_id " + - "AND members.instance_id = projections.users8_machines.instance_id " + - "LEFT JOIN projections.users8 " + - "ON members.user_id = projections.users8.id " + - "AND members.instance_id = projections.users8.instance_id " + + "LEFT JOIN projections.users9_humans " + + "ON members.user_id = projections.users9_humans.user_id " + + "AND members.instance_id = projections.users9_humans.instance_id " + + "LEFT JOIN projections.users9_machines " + + "ON members.user_id = projections.users9_machines.user_id " + + "AND members.instance_id = projections.users9_machines.instance_id " + + "LEFT JOIN projections.users9 " + + "ON members.user_id = projections.users9.id " + + "AND members.instance_id = projections.users9.instance_id " + "LEFT JOIN projections.login_names2 " + "ON members.user_id = projections.login_names2.user_id " + "AND members.instance_id = projections.login_names2.instance_id " + diff --git a/internal/query/project_grant_member_test.go b/internal/query/project_grant_member_test.go index adb1c506e5..de691e3b43 100644 --- a/internal/query/project_grant_member_test.go +++ b/internal/query/project_grant_member_test.go @@ -21,24 +21,24 @@ var ( ", members.user_id" + ", members.roles" + ", projections.login_names2.login_name" + - ", projections.users8_humans.email" + - ", projections.users8_humans.first_name" + - ", projections.users8_humans.last_name" + - ", projections.users8_humans.display_name" + - ", projections.users8_machines.name" + - ", projections.users8_humans.avatar_key" + - ", projections.users8.type" + + ", projections.users9_humans.email" + + ", projections.users9_humans.first_name" + + ", projections.users9_humans.last_name" + + ", projections.users9_humans.display_name" + + ", projections.users9_machines.name" + + ", projections.users9_humans.avatar_key" + + ", projections.users9.type" + ", COUNT(*) OVER () " + "FROM projections.project_grant_members3 AS members " + - "LEFT JOIN projections.users8_humans " + - "ON members.user_id = projections.users8_humans.user_id " + - "AND members.instance_id = projections.users8_humans.instance_id " + - "LEFT JOIN projections.users8_machines " + - "ON members.user_id = projections.users8_machines.user_id " + - "AND members.instance_id = projections.users8_machines.instance_id " + - "LEFT JOIN projections.users8 " + - "ON members.user_id = projections.users8.id " + - "AND members.instance_id = projections.users8.instance_id " + + "LEFT JOIN projections.users9_humans " + + "ON members.user_id = projections.users9_humans.user_id " + + "AND members.instance_id = projections.users9_humans.instance_id " + + "LEFT JOIN projections.users9_machines " + + "ON members.user_id = projections.users9_machines.user_id " + + "AND members.instance_id = projections.users9_machines.instance_id " + + "LEFT JOIN projections.users9 " + + "ON members.user_id = projections.users9.id " + + "AND members.instance_id = projections.users9.instance_id " + "LEFT JOIN projections.login_names2 " + "ON members.user_id = projections.login_names2.user_id " + "AND members.instance_id = projections.login_names2.instance_id " + diff --git a/internal/query/project_member_test.go b/internal/query/project_member_test.go index f102cff63f..79640f9247 100644 --- a/internal/query/project_member_test.go +++ b/internal/query/project_member_test.go @@ -21,24 +21,24 @@ var ( ", members.user_id" + ", members.roles" + ", projections.login_names2.login_name" + - ", projections.users8_humans.email" + - ", projections.users8_humans.first_name" + - ", projections.users8_humans.last_name" + - ", projections.users8_humans.display_name" + - ", projections.users8_machines.name" + - ", projections.users8_humans.avatar_key" + - ", projections.users8.type" + + ", projections.users9_humans.email" + + ", projections.users9_humans.first_name" + + ", projections.users9_humans.last_name" + + ", projections.users9_humans.display_name" + + ", projections.users9_machines.name" + + ", projections.users9_humans.avatar_key" + + ", projections.users9.type" + ", COUNT(*) OVER () " + "FROM projections.project_members3 AS members " + - "LEFT JOIN projections.users8_humans " + - "ON members.user_id = projections.users8_humans.user_id " + - "AND members.instance_id = projections.users8_humans.instance_id " + - "LEFT JOIN projections.users8_machines " + - "ON members.user_id = projections.users8_machines.user_id " + - "AND members.instance_id = projections.users8_machines.instance_id " + - "LEFT JOIN projections.users8 " + - "ON members.user_id = projections.users8.id " + - "AND members.instance_id = projections.users8.instance_id " + + "LEFT JOIN projections.users9_humans " + + "ON members.user_id = projections.users9_humans.user_id " + + "AND members.instance_id = projections.users9_humans.instance_id " + + "LEFT JOIN projections.users9_machines " + + "ON members.user_id = projections.users9_machines.user_id " + + "AND members.instance_id = projections.users9_machines.instance_id " + + "LEFT JOIN projections.users9 " + + "ON members.user_id = projections.users9.id " + + "AND members.instance_id = projections.users9.instance_id " + "LEFT JOIN projections.login_names2 " + "ON members.user_id = projections.login_names2.user_id " + "AND members.instance_id = projections.login_names2.instance_id " + diff --git a/internal/query/projection/user.go b/internal/query/projection/user.go index cafbbfee7d..3451e6fc37 100644 --- a/internal/query/projection/user.go +++ b/internal/query/projection/user.go @@ -15,7 +15,7 @@ import ( ) const ( - UserTable = "projections.users8" + UserTable = "projections.users9" UserHumanTable = UserTable + "_" + UserHumanSuffix UserMachineTable = UserTable + "_" + UserMachineSuffix UserNotifyTable = UserTable + "_" + UserNotifySuffix @@ -29,7 +29,6 @@ const ( UserInstanceIDCol = "instance_id" UserUsernameCol = "username" UserTypeCol = "type" - UserOwnerRemovedCol = "owner_removed" UserHumanSuffix = "humans" HumanUserIDCol = "user_id" @@ -94,12 +93,10 @@ func (*userProjection) Init() *old_handler.Check { handler.NewColumn(UserInstanceIDCol, handler.ColumnTypeText), handler.NewColumn(UserUsernameCol, handler.ColumnTypeText), handler.NewColumn(UserTypeCol, handler.ColumnTypeEnum), - handler.NewColumn(UserOwnerRemovedCol, handler.ColumnTypeBool, handler.Default(false)), }, handler.NewPrimaryKey(UserInstanceIDCol, UserIDCol), handler.WithIndex(handler.NewIndex("username", []string{UserUsernameCol})), handler.WithIndex(handler.NewIndex("resource_owner", []string{UserResourceOwnerCol})), - handler.WithIndex(handler.NewIndex("owner_removed", []string{UserOwnerRemovedCol})), ), handler.NewSuffixedTable([]*handler.InitColumn{ handler.NewColumn(HumanUserIDCol, handler.ColumnTypeText), diff --git a/internal/query/projection/user_test.go b/internal/query/projection/user_test.go index 66b4f65942..da4f2a860c 100644 --- a/internal/query/projection/user_test.go +++ b/internal/query/projection/user_test.go @@ -50,7 +50,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -64,7 +64,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + expectedStmt: "INSERT INTO projections.users9_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -79,7 +79,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -119,7 +119,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -133,7 +133,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + expectedStmt: "INSERT INTO projections.users9_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -148,7 +148,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -183,7 +183,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -197,7 +197,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + expectedStmt: "INSERT INTO projections.users9_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -212,7 +212,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -252,7 +252,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -266,7 +266,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + expectedStmt: "INSERT INTO projections.users9_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -281,7 +281,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -321,7 +321,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -335,7 +335,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + expectedStmt: "INSERT INTO projections.users9_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -350,7 +350,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -385,7 +385,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -399,7 +399,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + expectedStmt: "INSERT INTO projections.users9_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -414,7 +414,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -444,7 +444,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ domain.UserStateInitial, "agg-id", @@ -472,7 +472,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ domain.UserStateInitial, "agg-id", @@ -500,7 +500,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ domain.UserStateActive, "agg-id", @@ -528,7 +528,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9 SET state = $1 WHERE (id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ domain.UserStateActive, "agg-id", @@ -556,7 +556,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", + expectedStmt: "UPDATE projections.users9 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", expectedArgs: []interface{}{ anyArg{}, domain.UserStateLocked, @@ -586,7 +586,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", + expectedStmt: "UPDATE projections.users9 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", expectedArgs: []interface{}{ anyArg{}, domain.UserStateActive, @@ -616,7 +616,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", + expectedStmt: "UPDATE projections.users9 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", expectedArgs: []interface{}{ anyArg{}, domain.UserStateInactive, @@ -646,7 +646,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", + expectedStmt: "UPDATE projections.users9 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", expectedArgs: []interface{}{ anyArg{}, domain.UserStateActive, @@ -676,7 +676,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.users8 WHERE (id = $1) AND (instance_id = $2)", + expectedStmt: "DELETE FROM projections.users9 WHERE (id = $1) AND (instance_id = $2)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -705,7 +705,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", + expectedStmt: "UPDATE projections.users9 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", expectedArgs: []interface{}{ anyArg{}, "username", @@ -737,7 +737,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", + expectedStmt: "UPDATE projections.users9 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)", expectedArgs: []interface{}{ anyArg{}, "id@temporary.domain", @@ -774,7 +774,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -783,7 +783,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)", + expectedStmt: "UPDATE projections.users9_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)", expectedArgs: []interface{}{ "first-name", "last-name", @@ -823,7 +823,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -832,7 +832,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)", + expectedStmt: "UPDATE projections.users9_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)", expectedArgs: []interface{}{ "first-name", "last-name", @@ -867,7 +867,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -876,7 +876,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ domain.PhoneNumber("+41 00 000 00 00"), false, @@ -885,7 +885,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ &sql.NullString{String: "+41 00 000 00 00", Valid: true}, "agg-id", @@ -915,7 +915,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -924,7 +924,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ domain.PhoneNumber("+41 00 000 00 00"), false, @@ -933,7 +933,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ &sql.NullString{String: "+41 00 000 00 00", Valid: true}, "agg-id", @@ -961,7 +961,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -970,7 +970,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ nil, nil, @@ -979,7 +979,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ nil, nil, @@ -1008,7 +1008,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1017,7 +1017,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ nil, nil, @@ -1026,7 +1026,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ nil, nil, @@ -1055,7 +1055,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1064,7 +1064,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ true, "agg-id", @@ -1072,7 +1072,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)", + expectedStmt: "UPDATE projections.users9_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -1099,7 +1099,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1108,7 +1108,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ true, "agg-id", @@ -1116,7 +1116,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)", + expectedStmt: "UPDATE projections.users9_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -1145,7 +1145,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1154,7 +1154,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ domain.EmailAddress("email@zitadel.com"), false, @@ -1163,7 +1163,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ &sql.NullString{String: "email@zitadel.com", Valid: true}, "agg-id", @@ -1193,7 +1193,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1202,7 +1202,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ domain.EmailAddress("email@zitadel.com"), false, @@ -1211,7 +1211,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ &sql.NullString{String: "email@zitadel.com", Valid: true}, "agg-id", @@ -1239,7 +1239,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1248,7 +1248,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ true, "agg-id", @@ -1256,7 +1256,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)", + expectedStmt: "UPDATE projections.users9_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -1283,7 +1283,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1292,7 +1292,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ true, "agg-id", @@ -1300,7 +1300,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)", + expectedStmt: "UPDATE projections.users9_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -1329,7 +1329,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1338,7 +1338,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ "users/agg-id/avatar", "agg-id", @@ -1366,7 +1366,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1375,7 +1375,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ nil, "agg-id", @@ -1406,7 +1406,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -1420,7 +1420,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -1454,7 +1454,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "INSERT INTO projections.users8 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", + expectedStmt: "INSERT INTO projections.users9 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", expectedArgs: []interface{}{ "agg-id", anyArg{}, @@ -1468,7 +1468,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "INSERT INTO projections.users8_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)", + expectedStmt: "INSERT INTO projections.users9_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)", expectedArgs: []interface{}{ "agg-id", "instance-id", @@ -1501,7 +1501,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1510,7 +1510,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_machines SET (name, description) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9_machines SET (name, description) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ "machine-name", "description", @@ -1541,7 +1541,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1550,7 +1550,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_machines SET name = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_machines SET name = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ "machine-name", "agg-id", @@ -1580,7 +1580,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1589,7 +1589,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_machines SET description = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_machines SET description = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ "description", "agg-id", @@ -1638,7 +1638,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1647,7 +1647,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_machines SET has_secret = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_machines SET has_secret = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ true, "agg-id", @@ -1675,7 +1675,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "UPDATE projections.users8 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", + expectedStmt: "UPDATE projections.users9 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)", expectedArgs: []interface{}{ anyArg{}, uint64(15), @@ -1684,7 +1684,7 @@ func TestUserProjection_reduces(t *testing.T) { }, }, { - expectedStmt: "UPDATE projections.users8_machines SET has_secret = $1 WHERE (user_id = $2) AND (instance_id = $3)", + expectedStmt: "UPDATE projections.users9_machines SET has_secret = $1 WHERE (user_id = $2) AND (instance_id = $3)", expectedArgs: []interface{}{ false, "agg-id", @@ -1712,7 +1712,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.users8 WHERE (instance_id = $1) AND (resource_owner = $2)", + expectedStmt: "DELETE FROM projections.users9 WHERE (instance_id = $1) AND (resource_owner = $2)", expectedArgs: []interface{}{ "instance-id", "agg-id", @@ -1739,7 +1739,7 @@ func TestUserProjection_reduces(t *testing.T) { executer: &testExecuter{ executions: []execution{ { - expectedStmt: "DELETE FROM projections.users8 WHERE (instance_id = $1)", + expectedStmt: "DELETE FROM projections.users9 WHERE (instance_id = $1)", expectedArgs: []interface{}{ "agg-id", }, diff --git a/internal/query/sessions_test.go b/internal/query/sessions_test.go index d78bedbbd5..79a8b023bc 100644 --- a/internal/query/sessions_test.go +++ b/internal/query/sessions_test.go @@ -30,8 +30,8 @@ var ( ` projections.sessions7.user_id,` + ` projections.sessions7.user_checked_at,` + ` projections.login_names2.login_name,` + - ` projections.users8_humans.display_name,` + - ` projections.users8.resource_owner,` + + ` projections.users9_humans.display_name,` + + ` projections.users9.resource_owner,` + ` projections.sessions7.password_checked_at,` + ` projections.sessions7.intent_checked_at,` + ` projections.sessions7.webauthn_checked_at,` + @@ -48,8 +48,8 @@ var ( ` projections.sessions7.expiration` + ` FROM projections.sessions7` + ` LEFT JOIN projections.login_names2 ON projections.sessions7.user_id = projections.login_names2.user_id AND projections.sessions7.instance_id = projections.login_names2.instance_id` + - ` LEFT JOIN projections.users8_humans ON projections.sessions7.user_id = projections.users8_humans.user_id AND projections.sessions7.instance_id = projections.users8_humans.instance_id` + - ` LEFT JOIN projections.users8 ON projections.sessions7.user_id = projections.users8.id AND projections.sessions7.instance_id = projections.users8.instance_id` + + ` LEFT JOIN projections.users9_humans ON projections.sessions7.user_id = projections.users9_humans.user_id AND projections.sessions7.instance_id = projections.users9_humans.instance_id` + + ` LEFT JOIN projections.users9 ON projections.sessions7.user_id = projections.users9.id AND projections.sessions7.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms'`) expectedSessionsQuery = regexp.QuoteMeta(`SELECT projections.sessions7.id,` + ` projections.sessions7.creation_date,` + @@ -61,8 +61,8 @@ var ( ` projections.sessions7.user_id,` + ` projections.sessions7.user_checked_at,` + ` projections.login_names2.login_name,` + - ` projections.users8_humans.display_name,` + - ` projections.users8.resource_owner,` + + ` projections.users9_humans.display_name,` + + ` projections.users9.resource_owner,` + ` projections.sessions7.password_checked_at,` + ` projections.sessions7.intent_checked_at,` + ` projections.sessions7.webauthn_checked_at,` + @@ -75,8 +75,8 @@ var ( ` COUNT(*) OVER ()` + ` FROM projections.sessions7` + ` LEFT JOIN projections.login_names2 ON projections.sessions7.user_id = projections.login_names2.user_id AND projections.sessions7.instance_id = projections.login_names2.instance_id` + - ` LEFT JOIN projections.users8_humans ON projections.sessions7.user_id = projections.users8_humans.user_id AND projections.sessions7.instance_id = projections.users8_humans.instance_id` + - ` LEFT JOIN projections.users8 ON projections.sessions7.user_id = projections.users8.id AND projections.sessions7.instance_id = projections.users8.instance_id` + + ` LEFT JOIN projections.users9_humans ON projections.sessions7.user_id = projections.users9_humans.user_id AND projections.sessions7.instance_id = projections.users9_humans.instance_id` + + ` LEFT JOIN projections.users9 ON projections.sessions7.user_id = projections.users9.id AND projections.sessions7.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms'`) sessionCols = []string{ diff --git a/internal/query/user.go b/internal/query/user.go index e072a39e73..11dd51f92a 100644 --- a/internal/query/user.go +++ b/internal/query/user.go @@ -170,10 +170,6 @@ var ( name: projection.UserTypeCol, table: userTable, } - UserOwnerRemovedCol = Column{ - name: projection.UserOwnerRemovedCol, - table: userTable, - } userLoginNamesTable = loginNameTable.setAlias("login_names") userLoginNamesUserIDCol = LoginNameUserIDCol.setTable(userLoginNamesTable) @@ -327,7 +323,6 @@ var ( ) func addUserWithoutOwnerRemoved(eq map[string]interface{}) { - eq[UserOwnerRemovedCol.identifier()] = false eq[userLoginNamesOwnerRemovedUserCol.identifier()] = false eq[userLoginNamesOwnerRemovedPolicyCol.identifier()] = false eq[userLoginNamesOwnerRemovedDomainCol.identifier()] = false @@ -397,7 +392,7 @@ func (q *Queries) GetUser(ctx context.Context, shouldTriggerBulk bool, withOwner return user, err } -func (q *Queries) GetHumanProfile(ctx context.Context, userID string, withOwnerRemoved bool, queries ...SearchQuery) (profile *Profile, err error) { +func (q *Queries) GetHumanProfile(ctx context.Context, userID string, queries ...SearchQuery) (profile *Profile, err error) { ctx, span := tracing.NewSpan(ctx) defer func() { span.EndWithError(err) }() @@ -409,9 +404,6 @@ func (q *Queries) GetHumanProfile(ctx context.Context, userID string, withOwnerR UserIDCol.identifier(): userID, UserInstanceIDCol.identifier(): authz.GetInstance(ctx).InstanceID(), } - if !withOwnerRemoved { - eq[UserOwnerRemovedCol.identifier()] = false - } stmt, args, err := query.Where(eq).ToSql() if err != nil { return nil, errors.ThrowInternal(err, "QUERY-Dgbg2", "Errors.Query.SQLStatment") @@ -424,7 +416,7 @@ func (q *Queries) GetHumanProfile(ctx context.Context, userID string, withOwnerR return profile, err } -func (q *Queries) GetHumanEmail(ctx context.Context, userID string, withOwnerRemoved bool, queries ...SearchQuery) (email *Email, err error) { +func (q *Queries) GetHumanEmail(ctx context.Context, userID string, queries ...SearchQuery) (email *Email, err error) { ctx, span := tracing.NewSpan(ctx) defer func() { span.EndWithError(err) }() @@ -436,9 +428,6 @@ func (q *Queries) GetHumanEmail(ctx context.Context, userID string, withOwnerRem UserIDCol.identifier(): userID, UserInstanceIDCol.identifier(): authz.GetInstance(ctx).InstanceID(), } - if !withOwnerRemoved { - eq[UserOwnerRemovedCol.identifier()] = false - } stmt, args, err := query.Where(eq).ToSql() if err != nil { return nil, errors.ThrowInternal(err, "QUERY-BHhj3", "Errors.Query.SQLStatment") @@ -451,7 +440,7 @@ func (q *Queries) GetHumanEmail(ctx context.Context, userID string, withOwnerRem return email, err } -func (q *Queries) GetHumanPhone(ctx context.Context, userID string, withOwnerRemoved bool, queries ...SearchQuery) (phone *Phone, err error) { +func (q *Queries) GetHumanPhone(ctx context.Context, userID string, queries ...SearchQuery) (phone *Phone, err error) { ctx, span := tracing.NewSpan(ctx) defer func() { span.EndWithError(err) }() @@ -463,9 +452,6 @@ func (q *Queries) GetHumanPhone(ctx context.Context, userID string, withOwnerRem UserIDCol.identifier(): userID, UserInstanceIDCol.identifier(): authz.GetInstance(ctx).InstanceID(), } - if !withOwnerRemoved { - eq[UserOwnerRemovedCol.identifier()] = false - } stmt, args, err := query.Where(eq).ToSql() if err != nil { return nil, errors.ThrowInternal(err, "QUERY-Dg43g", "Errors.Query.SQLStatment") @@ -566,7 +552,7 @@ func (q *Queries) SearchUsers(ctx context.Context, queries *UserSearchQueries, w return users, err } -func (q *Queries) IsUserUnique(ctx context.Context, username, email, resourceOwner string, withOwnerRemoved bool) (isUnique bool, err error) { +func (q *Queries) IsUserUnique(ctx context.Context, username, email, resourceOwner string) (isUnique bool, err error) { ctx, span := tracing.NewSpan(ctx) defer func() { span.EndWithError(err) }() @@ -597,9 +583,6 @@ func (q *Queries) IsUserUnique(ctx context.Context, username, email, resourceOwn query = q.toQuery(query) } eq := sq.Eq{UserInstanceIDCol.identifier(): authz.GetInstance(ctx).InstanceID()} - if !withOwnerRemoved { - eq[UserOwnerRemovedCol.identifier()] = false - } stmt, args, err := query.Where(eq).ToSql() if err != nil { return false, errors.ThrowInternal(err, "QUERY-Dg43g", "Errors.Query.SQLStatment") diff --git a/internal/query/user_auth_method.go b/internal/query/user_auth_method.go index 9568179775..9341c13e6f 100644 --- a/internal/query/user_auth_method.go +++ b/internal/query/user_auth_method.go @@ -141,7 +141,7 @@ func (q *Queries) SearchUserAuthMethods(ctx context.Context, queries *UserAuthMe return userAuthMethods, err } -func (q *Queries) ListActiveUserAuthMethodTypes(ctx context.Context, userID string, withOwnerRemoved bool) (userAuthMethodTypes *AuthMethodTypes, err error) { +func (q *Queries) ListActiveUserAuthMethodTypes(ctx context.Context, userID string) (userAuthMethodTypes *AuthMethodTypes, err error) { ctxData := authz.GetCtxData(ctx) if ctxData.UserID != userID { if err := q.checkPermission(ctx, domain.PermissionUserRead, ctxData.OrgID, userID); err != nil { @@ -156,9 +156,6 @@ func (q *Queries) ListActiveUserAuthMethodTypes(ctx context.Context, userID stri UserIDCol.identifier(): userID, UserInstanceIDCol.identifier(): authz.GetInstance(ctx).InstanceID(), } - if !withOwnerRemoved { - eq[UserOwnerRemovedCol.identifier()] = false - } stmt, args, err := query.Where(eq).ToSql() if err != nil { return nil, errors.ThrowInvalidArgument(err, "QUERY-Sfdrg", "Errors.Query.InvalidRequest") @@ -175,7 +172,7 @@ func (q *Queries) ListActiveUserAuthMethodTypes(ctx context.Context, userID stri return userAuthMethodTypes, err } -func (q *Queries) ListUserAuthMethodTypesRequired(ctx context.Context, userID string, withOwnerRemoved bool) (userAuthMethodTypes []domain.UserAuthMethodType, forceMFA, forceMFALocalOnly bool, err error) { +func (q *Queries) ListUserAuthMethodTypesRequired(ctx context.Context, userID string) (userAuthMethodTypes []domain.UserAuthMethodType, forceMFA, forceMFALocalOnly bool, err error) { ctxData := authz.GetCtxData(ctx) if ctxData.UserID != userID { if err := q.checkPermission(ctx, domain.PermissionUserRead, ctxData.OrgID, userID); err != nil { @@ -190,9 +187,6 @@ func (q *Queries) ListUserAuthMethodTypesRequired(ctx context.Context, userID st UserIDCol.identifier(): userID, UserInstanceIDCol.identifier(): authz.GetInstance(ctx).InstanceID(), } - if !withOwnerRemoved { - eq[UserOwnerRemovedCol.identifier()] = false - } stmt, args, err := query.Where(eq).ToSql() if err != nil { return nil, false, false, errors.ThrowInvalidArgument(err, "QUERY-E5ut4", "Errors.Query.InvalidRequest") diff --git a/internal/query/user_auth_method_test.go b/internal/query/user_auth_method_test.go index 978e0e81a2..a9aae1d1c5 100644 --- a/internal/query/user_auth_method_test.go +++ b/internal/query/user_auth_method_test.go @@ -39,38 +39,38 @@ var ( "method_type", "count", } - prepareActiveAuthMethodTypesStmt = `SELECT projections.users8_notifications.password_set,` + + prepareActiveAuthMethodTypesStmt = `SELECT projections.users9_notifications.password_set,` + ` auth_method_types.method_type,` + ` user_idps_count.count` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_notifications ON projections.users8.id = projections.users8_notifications.user_id AND projections.users8.instance_id = projections.users8_notifications.instance_id` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_notifications ON projections.users9.id = projections.users9_notifications.user_id AND projections.users9.instance_id = projections.users9_notifications.instance_id` + ` LEFT JOIN (SELECT DISTINCT(auth_method_types.method_type), auth_method_types.user_id, auth_method_types.instance_id FROM projections.user_auth_methods4 AS auth_method_types` + ` WHERE auth_method_types.state = $1) AS auth_method_types` + - ` ON auth_method_types.user_id = projections.users8.id AND auth_method_types.instance_id = projections.users8.instance_id` + + ` ON auth_method_types.user_id = projections.users9.id AND auth_method_types.instance_id = projections.users9.instance_id` + ` LEFT JOIN (SELECT user_idps_count.user_id, user_idps_count.instance_id, COUNT(user_idps_count.user_id) AS count FROM projections.idp_user_links3 AS user_idps_count` + ` GROUP BY user_idps_count.user_id, user_idps_count.instance_id) AS user_idps_count` + - ` ON user_idps_count.user_id = projections.users8.id AND user_idps_count.instance_id = projections.users8.instance_id` + + ` ON user_idps_count.user_id = projections.users9.id AND user_idps_count.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms` prepareActiveAuthMethodTypesCols = []string{ "password_set", "method_type", "idps_count", } - prepareAuthMethodTypesRequiredStmt = `SELECT projections.users8_notifications.password_set,` + + prepareAuthMethodTypesRequiredStmt = `SELECT projections.users9_notifications.password_set,` + ` auth_method_types.method_type,` + ` user_idps_count.count,` + ` auth_methods_force_mfa.force_mfa,` + ` auth_methods_force_mfa.force_mfa_local_only` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_notifications ON projections.users8.id = projections.users8_notifications.user_id AND projections.users8.instance_id = projections.users8_notifications.instance_id` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_notifications ON projections.users9.id = projections.users9_notifications.user_id AND projections.users9.instance_id = projections.users9_notifications.instance_id` + ` LEFT JOIN (SELECT DISTINCT(auth_method_types.method_type), auth_method_types.user_id, auth_method_types.instance_id FROM projections.user_auth_methods4 AS auth_method_types` + ` WHERE auth_method_types.state = $1) AS auth_method_types` + - ` ON auth_method_types.user_id = projections.users8.id AND auth_method_types.instance_id = projections.users8.instance_id` + + ` ON auth_method_types.user_id = projections.users9.id AND auth_method_types.instance_id = projections.users9.instance_id` + ` LEFT JOIN (SELECT user_idps_count.user_id, user_idps_count.instance_id, COUNT(user_idps_count.user_id) AS count FROM projections.idp_user_links3 AS user_idps_count` + ` GROUP BY user_idps_count.user_id, user_idps_count.instance_id) AS user_idps_count` + - ` ON user_idps_count.user_id = projections.users8.id AND user_idps_count.instance_id = projections.users8.instance_id` + + ` ON user_idps_count.user_id = projections.users9.id AND user_idps_count.instance_id = projections.users9.instance_id` + ` LEFT JOIN (SELECT auth_methods_force_mfa.force_mfa, auth_methods_force_mfa.force_mfa_local_only, auth_methods_force_mfa.instance_id, auth_methods_force_mfa.aggregate_id FROM projections.login_policies5 AS auth_methods_force_mfa ORDER BY auth_methods_force_mfa.is_default) AS auth_methods_force_mfa` + - ` ON (auth_methods_force_mfa.aggregate_id = projections.users8.instance_id OR auth_methods_force_mfa.aggregate_id = projections.users8.resource_owner) AND auth_methods_force_mfa.instance_id = projections.users8.instance_id` + + ` ON (auth_methods_force_mfa.aggregate_id = projections.users9.instance_id OR auth_methods_force_mfa.aggregate_id = projections.users9.resource_owner) AND auth_methods_force_mfa.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms ` prepareAuthMethodTypesRequiredCols = []string{ diff --git a/internal/query/user_grant_test.go b/internal/query/user_grant_test.go index 918003f615..a8282a8c75 100644 --- a/internal/query/user_grant_test.go +++ b/internal/query/user_grant_test.go @@ -23,14 +23,14 @@ var ( ", projections.user_grants3.roles" + ", projections.user_grants3.state" + ", projections.user_grants3.user_id" + - ", projections.users8.username" + - ", projections.users8.type" + - ", projections.users8.resource_owner" + - ", projections.users8_humans.first_name" + - ", projections.users8_humans.last_name" + - ", projections.users8_humans.email" + - ", projections.users8_humans.display_name" + - ", projections.users8_humans.avatar_key" + + ", projections.users9.username" + + ", projections.users9.type" + + ", projections.users9.resource_owner" + + ", projections.users9_humans.first_name" + + ", projections.users9_humans.last_name" + + ", projections.users9_humans.email" + + ", projections.users9_humans.display_name" + + ", projections.users9_humans.avatar_key" + ", projections.login_names2.login_name" + ", projections.user_grants3.resource_owner" + ", projections.orgs1.name" + @@ -38,8 +38,8 @@ var ( ", projections.user_grants3.project_id" + ", projections.projects3.name" + " FROM projections.user_grants3" + - " LEFT JOIN projections.users8 ON projections.user_grants3.user_id = projections.users8.id AND projections.user_grants3.instance_id = projections.users8.instance_id" + - " LEFT JOIN projections.users8_humans ON projections.user_grants3.user_id = projections.users8_humans.user_id AND projections.user_grants3.instance_id = projections.users8_humans.instance_id" + + " LEFT JOIN projections.users9 ON projections.user_grants3.user_id = projections.users9.id AND projections.user_grants3.instance_id = projections.users9.instance_id" + + " LEFT JOIN projections.users9_humans ON projections.user_grants3.user_id = projections.users9_humans.user_id AND projections.user_grants3.instance_id = projections.users9_humans.instance_id" + " LEFT JOIN projections.orgs1 ON projections.user_grants3.resource_owner = projections.orgs1.id AND projections.user_grants3.instance_id = projections.orgs1.instance_id" + " LEFT JOIN projections.projects3 ON projections.user_grants3.project_id = projections.projects3.id AND projections.user_grants3.instance_id = projections.projects3.instance_id" + " LEFT JOIN projections.login_names2 ON projections.user_grants3.user_id = projections.login_names2.user_id AND projections.user_grants3.instance_id = projections.login_names2.instance_id" + @@ -78,14 +78,14 @@ var ( ", projections.user_grants3.roles" + ", projections.user_grants3.state" + ", projections.user_grants3.user_id" + - ", projections.users8.username" + - ", projections.users8.type" + - ", projections.users8.resource_owner" + - ", projections.users8_humans.first_name" + - ", projections.users8_humans.last_name" + - ", projections.users8_humans.email" + - ", projections.users8_humans.display_name" + - ", projections.users8_humans.avatar_key" + + ", projections.users9.username" + + ", projections.users9.type" + + ", projections.users9.resource_owner" + + ", projections.users9_humans.first_name" + + ", projections.users9_humans.last_name" + + ", projections.users9_humans.email" + + ", projections.users9_humans.display_name" + + ", projections.users9_humans.avatar_key" + ", projections.login_names2.login_name" + ", projections.user_grants3.resource_owner" + ", projections.orgs1.name" + @@ -94,8 +94,8 @@ var ( ", projections.projects3.name" + ", COUNT(*) OVER ()" + " FROM projections.user_grants3" + - " LEFT JOIN projections.users8 ON projections.user_grants3.user_id = projections.users8.id AND projections.user_grants3.instance_id = projections.users8.instance_id" + - " LEFT JOIN projections.users8_humans ON projections.user_grants3.user_id = projections.users8_humans.user_id AND projections.user_grants3.instance_id = projections.users8_humans.instance_id" + + " LEFT JOIN projections.users9 ON projections.user_grants3.user_id = projections.users9.id AND projections.user_grants3.instance_id = projections.users9.instance_id" + + " LEFT JOIN projections.users9_humans ON projections.user_grants3.user_id = projections.users9_humans.user_id AND projections.user_grants3.instance_id = projections.users9_humans.instance_id" + " LEFT JOIN projections.orgs1 ON projections.user_grants3.resource_owner = projections.orgs1.id AND projections.user_grants3.instance_id = projections.orgs1.instance_id" + " LEFT JOIN projections.projects3 ON projections.user_grants3.project_id = projections.projects3.id AND projections.user_grants3.instance_id = projections.projects3.instance_id" + " LEFT JOIN projections.login_names2 ON projections.user_grants3.user_id = projections.login_names2.user_id AND projections.user_grants3.instance_id = projections.login_names2.instance_id" + diff --git a/internal/query/user_test.go b/internal/query/user_test.go index 866cab0cad..602807d631 100644 --- a/internal/query/user_test.go +++ b/internal/query/user_test.go @@ -22,43 +22,43 @@ var ( preferredLoginNameQuery = `SELECT preferred_login_name.user_id, preferred_login_name.login_name, preferred_login_name.instance_id, preferred_login_name.user_owner_removed, preferred_login_name.policy_owner_removed, preferred_login_name.domain_owner_removed` + ` FROM projections.login_names2 AS preferred_login_name` + ` WHERE preferred_login_name.is_primary = $1` - userQuery = `SELECT projections.users8.id,` + - ` projections.users8.creation_date,` + - ` projections.users8.change_date,` + - ` projections.users8.resource_owner,` + - ` projections.users8.sequence,` + - ` projections.users8.state,` + - ` projections.users8.type,` + - ` projections.users8.username,` + + userQuery = `SELECT projections.users9.id,` + + ` projections.users9.creation_date,` + + ` projections.users9.change_date,` + + ` projections.users9.resource_owner,` + + ` projections.users9.sequence,` + + ` projections.users9.state,` + + ` projections.users9.type,` + + ` projections.users9.username,` + ` login_names.loginnames,` + ` preferred_login_name.login_name,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.first_name,` + - ` projections.users8_humans.last_name,` + - ` projections.users8_humans.nick_name,` + - ` projections.users8_humans.display_name,` + - ` projections.users8_humans.preferred_language,` + - ` projections.users8_humans.gender,` + - ` projections.users8_humans.avatar_key,` + - ` projections.users8_humans.email,` + - ` projections.users8_humans.is_email_verified,` + - ` projections.users8_humans.phone,` + - ` projections.users8_humans.is_phone_verified,` + - ` projections.users8_machines.user_id,` + - ` projections.users8_machines.name,` + - ` projections.users8_machines.description,` + - ` projections.users8_machines.has_secret,` + - ` projections.users8_machines.access_token_type,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.first_name,` + + ` projections.users9_humans.last_name,` + + ` projections.users9_humans.nick_name,` + + ` projections.users9_humans.display_name,` + + ` projections.users9_humans.preferred_language,` + + ` projections.users9_humans.gender,` + + ` projections.users9_humans.avatar_key,` + + ` projections.users9_humans.email,` + + ` projections.users9_humans.is_email_verified,` + + ` projections.users9_humans.phone,` + + ` projections.users9_humans.is_phone_verified,` + + ` projections.users9_machines.user_id,` + + ` projections.users9_machines.name,` + + ` projections.users9_machines.description,` + + ` projections.users9_machines.has_secret,` + + ` projections.users9_machines.access_token_type,` + ` COUNT(*) OVER ()` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + - ` LEFT JOIN projections.users8_machines ON projections.users8.id = projections.users8_machines.user_id AND projections.users8.instance_id = projections.users8_machines.instance_id` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + + ` LEFT JOIN projections.users9_machines ON projections.users9.id = projections.users9_machines.user_id AND projections.users9.instance_id = projections.users9_machines.instance_id` + ` LEFT JOIN` + ` (` + loginNamesQuery + `) AS login_names` + - ` ON login_names.user_id = projections.users8.id AND login_names.instance_id = projections.users8.instance_id` + + ` ON login_names.user_id = projections.users9.id AND login_names.instance_id = projections.users9.instance_id` + ` LEFT JOIN` + ` (` + preferredLoginNameQuery + `) AS preferred_login_name` + - ` ON preferred_login_name.user_id = projections.users8.id AND preferred_login_name.instance_id = projections.users8.instance_id` + + ` ON preferred_login_name.user_id = projections.users9.id AND preferred_login_name.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` userCols = []string{ "id", @@ -92,21 +92,21 @@ var ( "access_token_type", "count", } - profileQuery = `SELECT projections.users8.id,` + - ` projections.users8.creation_date,` + - ` projections.users8.change_date,` + - ` projections.users8.resource_owner,` + - ` projections.users8.sequence,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.first_name,` + - ` projections.users8_humans.last_name,` + - ` projections.users8_humans.nick_name,` + - ` projections.users8_humans.display_name,` + - ` projections.users8_humans.preferred_language,` + - ` projections.users8_humans.gender,` + - ` projections.users8_humans.avatar_key` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + + profileQuery = `SELECT projections.users9.id,` + + ` projections.users9.creation_date,` + + ` projections.users9.change_date,` + + ` projections.users9.resource_owner,` + + ` projections.users9.sequence,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.first_name,` + + ` projections.users9_humans.last_name,` + + ` projections.users9_humans.nick_name,` + + ` projections.users9_humans.display_name,` + + ` projections.users9_humans.preferred_language,` + + ` projections.users9_humans.gender,` + + ` projections.users9_humans.avatar_key` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` profileCols = []string{ "id", @@ -123,16 +123,16 @@ var ( "gender", "avatar_key", } - emailQuery = `SELECT projections.users8.id,` + - ` projections.users8.creation_date,` + - ` projections.users8.change_date,` + - ` projections.users8.resource_owner,` + - ` projections.users8.sequence,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.email,` + - ` projections.users8_humans.is_email_verified` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + + emailQuery = `SELECT projections.users9.id,` + + ` projections.users9.creation_date,` + + ` projections.users9.change_date,` + + ` projections.users9.resource_owner,` + + ` projections.users9.sequence,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.email,` + + ` projections.users9_humans.is_email_verified` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` emailCols = []string{ "id", @@ -144,16 +144,16 @@ var ( "email", "is_email_verified", } - phoneQuery = `SELECT projections.users8.id,` + - ` projections.users8.creation_date,` + - ` projections.users8.change_date,` + - ` projections.users8.resource_owner,` + - ` projections.users8.sequence,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.phone,` + - ` projections.users8_humans.is_phone_verified` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + + phoneQuery = `SELECT projections.users9.id,` + + ` projections.users9.creation_date,` + + ` projections.users9.change_date,` + + ` projections.users9.resource_owner,` + + ` projections.users9.sequence,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.phone,` + + ` projections.users9_humans.is_phone_verified` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` phoneCols = []string{ "id", @@ -165,14 +165,14 @@ var ( "phone", "is_phone_verified", } - userUniqueQuery = `SELECT projections.users8.id,` + - ` projections.users8.state,` + - ` projections.users8.username,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.email,` + - ` projections.users8_humans.is_email_verified` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + + userUniqueQuery = `SELECT projections.users9.id,` + + ` projections.users9.state,` + + ` projections.users9.username,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.email,` + + ` projections.users9_humans.is_email_verified` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` userUniqueCols = []string{ "id", @@ -182,40 +182,40 @@ var ( "email", "is_email_verified", } - notifyUserQuery = `SELECT projections.users8.id,` + - ` projections.users8.creation_date,` + - ` projections.users8.change_date,` + - ` projections.users8.resource_owner,` + - ` projections.users8.sequence,` + - ` projections.users8.state,` + - ` projections.users8.type,` + - ` projections.users8.username,` + + notifyUserQuery = `SELECT projections.users9.id,` + + ` projections.users9.creation_date,` + + ` projections.users9.change_date,` + + ` projections.users9.resource_owner,` + + ` projections.users9.sequence,` + + ` projections.users9.state,` + + ` projections.users9.type,` + + ` projections.users9.username,` + ` login_names.loginnames,` + ` preferred_login_name.login_name,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.first_name,` + - ` projections.users8_humans.last_name,` + - ` projections.users8_humans.nick_name,` + - ` projections.users8_humans.display_name,` + - ` projections.users8_humans.preferred_language,` + - ` projections.users8_humans.gender,` + - ` projections.users8_humans.avatar_key,` + - ` projections.users8_notifications.user_id,` + - ` projections.users8_notifications.last_email,` + - ` projections.users8_notifications.verified_email,` + - ` projections.users8_notifications.last_phone,` + - ` projections.users8_notifications.verified_phone,` + - ` projections.users8_notifications.password_set,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.first_name,` + + ` projections.users9_humans.last_name,` + + ` projections.users9_humans.nick_name,` + + ` projections.users9_humans.display_name,` + + ` projections.users9_humans.preferred_language,` + + ` projections.users9_humans.gender,` + + ` projections.users9_humans.avatar_key,` + + ` projections.users9_notifications.user_id,` + + ` projections.users9_notifications.last_email,` + + ` projections.users9_notifications.verified_email,` + + ` projections.users9_notifications.last_phone,` + + ` projections.users9_notifications.verified_phone,` + + ` projections.users9_notifications.password_set,` + ` COUNT(*) OVER ()` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + - ` LEFT JOIN projections.users8_notifications ON projections.users8.id = projections.users8_notifications.user_id AND projections.users8.instance_id = projections.users8_notifications.instance_id` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + + ` LEFT JOIN projections.users9_notifications ON projections.users9.id = projections.users9_notifications.user_id AND projections.users9.instance_id = projections.users9_notifications.instance_id` + ` LEFT JOIN` + ` (` + loginNamesQuery + `) AS login_names` + - ` ON login_names.user_id = projections.users8.id AND login_names.instance_id = projections.users8.instance_id` + + ` ON login_names.user_id = projections.users9.id AND login_names.instance_id = projections.users9.instance_id` + ` LEFT JOIN` + ` (` + preferredLoginNameQuery + `) AS preferred_login_name` + - ` ON preferred_login_name.user_id = projections.users8.id AND preferred_login_name.instance_id = projections.users8.instance_id` + + ` ON preferred_login_name.user_id = projections.users9.id AND preferred_login_name.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` notifyUserCols = []string{ "id", @@ -246,43 +246,43 @@ var ( "password_set", "count", } - usersQuery = `SELECT projections.users8.id,` + - ` projections.users8.creation_date,` + - ` projections.users8.change_date,` + - ` projections.users8.resource_owner,` + - ` projections.users8.sequence,` + - ` projections.users8.state,` + - ` projections.users8.type,` + - ` projections.users8.username,` + + usersQuery = `SELECT projections.users9.id,` + + ` projections.users9.creation_date,` + + ` projections.users9.change_date,` + + ` projections.users9.resource_owner,` + + ` projections.users9.sequence,` + + ` projections.users9.state,` + + ` projections.users9.type,` + + ` projections.users9.username,` + ` login_names.loginnames,` + ` preferred_login_name.login_name,` + - ` projections.users8_humans.user_id,` + - ` projections.users8_humans.first_name,` + - ` projections.users8_humans.last_name,` + - ` projections.users8_humans.nick_name,` + - ` projections.users8_humans.display_name,` + - ` projections.users8_humans.preferred_language,` + - ` projections.users8_humans.gender,` + - ` projections.users8_humans.avatar_key,` + - ` projections.users8_humans.email,` + - ` projections.users8_humans.is_email_verified,` + - ` projections.users8_humans.phone,` + - ` projections.users8_humans.is_phone_verified,` + - ` projections.users8_machines.user_id,` + - ` projections.users8_machines.name,` + - ` projections.users8_machines.description,` + - ` projections.users8_machines.has_secret,` + - ` projections.users8_machines.access_token_type,` + + ` projections.users9_humans.user_id,` + + ` projections.users9_humans.first_name,` + + ` projections.users9_humans.last_name,` + + ` projections.users9_humans.nick_name,` + + ` projections.users9_humans.display_name,` + + ` projections.users9_humans.preferred_language,` + + ` projections.users9_humans.gender,` + + ` projections.users9_humans.avatar_key,` + + ` projections.users9_humans.email,` + + ` projections.users9_humans.is_email_verified,` + + ` projections.users9_humans.phone,` + + ` projections.users9_humans.is_phone_verified,` + + ` projections.users9_machines.user_id,` + + ` projections.users9_machines.name,` + + ` projections.users9_machines.description,` + + ` projections.users9_machines.has_secret,` + + ` projections.users9_machines.access_token_type,` + ` COUNT(*) OVER ()` + - ` FROM projections.users8` + - ` LEFT JOIN projections.users8_humans ON projections.users8.id = projections.users8_humans.user_id AND projections.users8.instance_id = projections.users8_humans.instance_id` + - ` LEFT JOIN projections.users8_machines ON projections.users8.id = projections.users8_machines.user_id AND projections.users8.instance_id = projections.users8_machines.instance_id` + + ` FROM projections.users9` + + ` LEFT JOIN projections.users9_humans ON projections.users9.id = projections.users9_humans.user_id AND projections.users9.instance_id = projections.users9_humans.instance_id` + + ` LEFT JOIN projections.users9_machines ON projections.users9.id = projections.users9_machines.user_id AND projections.users9.instance_id = projections.users9_machines.instance_id` + ` LEFT JOIN` + ` (` + loginNamesQuery + `) AS login_names` + - ` ON login_names.user_id = projections.users8.id AND login_names.instance_id = projections.users8.instance_id` + + ` ON login_names.user_id = projections.users9.id AND login_names.instance_id = projections.users9.instance_id` + ` LEFT JOIN` + ` (` + preferredLoginNameQuery + `) AS preferred_login_name` + - ` ON preferred_login_name.user_id = projections.users8.id AND preferred_login_name.instance_id = projections.users8.instance_id` + + ` ON preferred_login_name.user_id = projections.users9.id AND preferred_login_name.instance_id = projections.users9.instance_id` + ` AS OF SYSTEM TIME '-1 ms'` usersCols = []string{ "id",