diff --git a/console/src/app/pages/org-create/org-create.component.html b/console/src/app/pages/org-create/org-create.component.html
index 5dafb01429..1672159ca0 100644
--- a/console/src/app/pages/org-create/org-create.component.html
+++ b/console/src/app/pages/org-create/org-create.component.html
@@ -170,7 +170,7 @@
{{ 'ORG_DETAIL.DETAIL.NAME' | translate }}
-
+
@@ -182,6 +182,7 @@
class="big-button"
cdkFocusInitial
type="submit"
+ data-e2e="create-org-button"
>
{{ 'ACTIONS.CREATE' | translate }}
diff --git a/console/src/assets/i18n/bg.json b/console/src/assets/i18n/bg.json
index b3407a41f9..2984346769 100644
--- a/console/src/assets/i18n/bg.json
+++ b/console/src/assets/i18n/bg.json
@@ -957,8 +957,7 @@
"STATE": {
"0": "Не е дефинирано",
"1": "Активен",
- "2": "Деактивиран",
- "3": "Премахнато"
+ "2": "Деактивиран"
},
"MEMBER": {
"TITLE": "Мениджъри на организации",
diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json
index daa3b704ee..a2330d04af 100644
--- a/console/src/assets/i18n/de.json
+++ b/console/src/assets/i18n/de.json
@@ -963,8 +963,7 @@
"STATE": {
"0": "Nicht definiert",
"1": "Aktiv",
- "2": "Inaktiv",
- "3": "Entfernt"
+ "2": "Inaktiv"
},
"MEMBER": {
"TITLE": "Manager der Organisation verwalten",
diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json
index 9c8daa3c30..cba525624e 100644
--- a/console/src/assets/i18n/en.json
+++ b/console/src/assets/i18n/en.json
@@ -964,8 +964,7 @@
"STATE": {
"0": "Not defined",
"1": "Active",
- "2": "Deactivated",
- "3": "Removed"
+ "2": "Deactivated"
},
"MEMBER": {
"TITLE": "Organization Managers",
diff --git a/console/src/assets/i18n/es.json b/console/src/assets/i18n/es.json
index 5d12e95524..abb877423b 100644
--- a/console/src/assets/i18n/es.json
+++ b/console/src/assets/i18n/es.json
@@ -964,8 +964,7 @@
"STATE": {
"0": "No definida",
"1": "Activa",
- "2": "Desactivada",
- "3": "Eliminada"
+ "2": "Desactivada"
},
"MEMBER": {
"TITLE": "Mánagers de la organización",
diff --git a/console/src/assets/i18n/fr.json b/console/src/assets/i18n/fr.json
index c5a8f2b60a..8cc362ffdf 100644
--- a/console/src/assets/i18n/fr.json
+++ b/console/src/assets/i18n/fr.json
@@ -963,8 +963,7 @@
"STATE": {
"0": "Non défini",
"1": "Actif",
- "2": "Désactivé",
- "3": "Supprimé"
+ "2": "Désactivé"
},
"MEMBER": {
"TITLE": "Gestionnaires de l'organisation",
diff --git a/console/src/assets/i18n/it.json b/console/src/assets/i18n/it.json
index c1fc647d16..36cb26f7d6 100644
--- a/console/src/assets/i18n/it.json
+++ b/console/src/assets/i18n/it.json
@@ -963,8 +963,7 @@
"STATE": {
"0": "Non definito",
"1": "Attivo",
- "2": "Disattivato",
- "3": "Rimosso"
+ "2": "Disattivato"
},
"MEMBER": {
"TITLE": "Manager dell'organizzazione",
diff --git a/console/src/assets/i18n/ja.json b/console/src/assets/i18n/ja.json
index 73d3cef814..0857b1b249 100644
--- a/console/src/assets/i18n/ja.json
+++ b/console/src/assets/i18n/ja.json
@@ -964,8 +964,7 @@
"STATE": {
"0": "未定義",
"1": "アクティブ",
- "2": "非アクティブ",
- "3": "削除"
+ "2": "非アクティブ"
},
"MEMBER": {
"TITLE": "組織マネージャー",
diff --git a/console/src/assets/i18n/pl.json b/console/src/assets/i18n/pl.json
index a29ec6ad95..ddc06cc518 100644
--- a/console/src/assets/i18n/pl.json
+++ b/console/src/assets/i18n/pl.json
@@ -963,8 +963,7 @@
"STATE": {
"0": "Nieokreślone",
"1": "Aktywne",
- "2": "Dezaktywowane",
- "3": "Usunięte"
+ "2": "Dezaktywowane"
},
"MEMBER": {
"TITLE": "Menadżerowie organizacji",
diff --git a/console/src/assets/i18n/zh.json b/console/src/assets/i18n/zh.json
index 3a3a5c2115..a09aab1bcc 100644
--- a/console/src/assets/i18n/zh.json
+++ b/console/src/assets/i18n/zh.json
@@ -963,8 +963,7 @@
"STATE": {
"0": "未定义",
"1": "启用",
- "2": "停用",
- "3": "移除"
+ "2": "停用"
},
"MEMBER": {
"TITLE": "组织管理者",
diff --git a/e2e/cypress/e2e/organization/organizations.cy.ts b/e2e/cypress/e2e/organization/organizations.cy.ts
index 83531c1ce3..6cf1185fe9 100644
--- a/e2e/cypress/e2e/organization/organizations.cy.ts
+++ b/e2e/cypress/e2e/organization/organizations.cy.ts
@@ -3,15 +3,38 @@ import { v4 as uuidv4 } from 'uuid';
import { Context } from 'support/commands';
const orgPath = `/org`;
+const orgsPath = `/orgs`;
+const orgsPathCreate = `/orgs/create`;
const orgNameOnCreation = 'e2eorgrename';
const testOrgNameChange = uuidv4();
+const newOrg = uuidv4();
beforeEach(() => {
cy.context().as('ctx');
});
describe('organizations', () => {
+ describe('add and delete org', () => {
+ it('should create an org', () => {
+ cy.visit(orgsPathCreate);
+ cy.get('[data-e2e="org-name-input"]').focus().clear().type(newOrg);
+ cy.get('[data-e2e="create-org-button"]').click();
+ cy.contains('tr', newOrg);
+ });
+
+ it('should delete an org', () => {
+ cy.visit(orgsPath);
+ cy.contains('tr', newOrg).click();
+ cy.get('[data-e2e="actions"]').click();
+ cy.get('[data-e2e="delete"]', { timeout: 1000 }).should('be.visible').click();
+ cy.get('[data-e2e="confirm-dialog-input"]').focus().clear().type(newOrg);
+ cy.get('[data-e2e="confirm-dialog-button"]').click();
+ cy.shouldConfirmSuccess();
+ cy.contains('tr', newOrg).should('not.exist');
+ });
+ });
+
describe('rename', () => {
beforeEach(() => {
cy.get('@ctx').then((ctx) => {
diff --git a/internal/api/grpc/org/converter.go b/internal/api/grpc/org/converter.go
index a73d77a279..142df950e5 100644
--- a/internal/api/grpc/org/converter.go
+++ b/internal/api/grpc/org/converter.go
@@ -103,8 +103,6 @@ func OrgStateToPb(state domain.OrgState) org_pb.OrgState {
return org_pb.OrgState_ORG_STATE_ACTIVE
case domain.OrgStateInactive:
return org_pb.OrgState_ORG_STATE_INACTIVE
- case domain.OrgStateRemoved:
- return org_pb.OrgState_ORG_STATE_REMOVED
default:
return org_pb.OrgState_ORG_STATE_UNSPECIFIED
}
@@ -116,8 +114,6 @@ func OrgStateToDomain(state org_pb.OrgState) domain.OrgState {
return domain.OrgStateActive
case org_pb.OrgState_ORG_STATE_INACTIVE:
return domain.OrgStateInactive
- case org_pb.OrgState_ORG_STATE_REMOVED:
- return domain.OrgStateRemoved
case org_pb.OrgState_ORG_STATE_UNSPECIFIED:
fallthrough
default:
diff --git a/internal/command/org_test.go b/internal/command/org_test.go
index e67ba69dc8..8696b3fb26 100644
--- a/internal/command/org_test.go
+++ b/internal/command/org_test.go
@@ -1088,34 +1088,6 @@ func TestCommandSide_RemoveOrg(t *testing.T) {
err: errors.IsNotFound,
},
},
- {
- name: "org already removed, error",
- fields: fields{
- eventstore: eventstoreExpect(
- t,
- expectFilter(), // zitadel project check
- expectFilter(
- eventFromEventPusher(
- org.NewOrgAddedEvent(context.Background(),
- &org.NewAggregate("org1").Aggregate,
- "org"),
- ),
- eventFromEventPusher(
- org.NewOrgRemovedEvent(context.Background(),
- &org.NewAggregate("org1").Aggregate,
- "org", []string{}, false, []string{}, []*domain.UserIDPLink{}, []string{}),
- ),
- ),
- ),
- },
- args: args{
- ctx: context.Background(),
- orgID: "org1",
- },
- res: res{
- err: errors.IsNotFound,
- },
- },
{
name: "push failed, error",
fields: fields{
diff --git a/internal/query/org.go b/internal/query/org.go
index 6ba4b54dc6..e99878f63e 100644
--- a/internal/query/org.go
+++ b/internal/query/org.go
@@ -214,8 +214,10 @@ func (q *Queries) SearchOrgs(ctx context.Context, queries *OrgSearchQueries) (or
query, scan := prepareOrgsQuery(ctx, q.client)
stmt, args, err := queries.toQuery(query).
- Where(sq.Eq{
- OrgColumnInstanceID.identifier(): authz.GetInstance(ctx).InstanceID(),
+ Where(sq.And{
+ sq.Eq{
+ OrgColumnInstanceID.identifier(): authz.GetInstance(ctx).InstanceID(),
+ },
}).ToSql()
if err != nil {
return nil, errors.ThrowInvalidArgument(err, "QUERY-wQ3by", "Errors.Query.InvalidRequest")
diff --git a/internal/query/org_test.go b/internal/query/org_test.go
index c4c2c21ad5..55e9546297 100644
--- a/internal/query/org_test.go
+++ b/internal/query/org_test.go
@@ -17,19 +17,19 @@ import (
)
var (
- orgUniqueQuery = "SELECT COUNT(*) = 0 FROM projections.orgs LEFT JOIN projections.org_domains2 ON projections.orgs.id = projections.org_domains2.org_id AND projections.orgs.instance_id = projections.org_domains2.instance_id AS OF SYSTEM TIME '-1 ms' WHERE (projections.org_domains2.is_verified = $1 AND projections.orgs.instance_id = $2 AND (projections.org_domains2.domain ILIKE $3 OR projections.orgs.name ILIKE $4) AND projections.orgs.org_state <> $5)"
+ orgUniqueQuery = "SELECT COUNT(*) = 0 FROM projections.orgs1 LEFT JOIN projections.org_domains2 ON projections.orgs1.id = projections.org_domains2.org_id AND projections.orgs1.instance_id = projections.org_domains2.instance_id AS OF SYSTEM TIME '-1 ms' WHERE (projections.org_domains2.is_verified = $1 AND projections.orgs1.instance_id = $2 AND (projections.org_domains2.domain ILIKE $3 OR projections.orgs1.name ILIKE $4) AND projections.orgs1.org_state <> $5)"
orgUniqueCols = []string{"is_unique"}
- prepareOrgsQueryStmt = `SELECT projections.orgs.id,` +
- ` projections.orgs.creation_date,` +
- ` projections.orgs.change_date,` +
- ` projections.orgs.resource_owner,` +
- ` projections.orgs.org_state,` +
- ` projections.orgs.sequence,` +
- ` projections.orgs.name,` +
- ` projections.orgs.primary_domain,` +
+ prepareOrgsQueryStmt = `SELECT projections.orgs1.id,` +
+ ` projections.orgs1.creation_date,` +
+ ` projections.orgs1.change_date,` +
+ ` projections.orgs1.resource_owner,` +
+ ` projections.orgs1.org_state,` +
+ ` projections.orgs1.sequence,` +
+ ` projections.orgs1.name,` +
+ ` projections.orgs1.primary_domain,` +
` COUNT(*) OVER ()` +
- ` FROM projections.orgs` +
+ ` FROM projections.orgs1` +
` AS OF SYSTEM TIME '-1 ms' `
prepareOrgsQueryCols = []string{
"id",
@@ -43,15 +43,15 @@ var (
"count",
}
- prepareOrgQueryStmt = `SELECT projections.orgs.id,` +
- ` projections.orgs.creation_date,` +
- ` projections.orgs.change_date,` +
- ` projections.orgs.resource_owner,` +
- ` projections.orgs.org_state,` +
- ` projections.orgs.sequence,` +
- ` projections.orgs.name,` +
- ` projections.orgs.primary_domain` +
- ` FROM projections.orgs` +
+ prepareOrgQueryStmt = `SELECT projections.orgs1.id,` +
+ ` projections.orgs1.creation_date,` +
+ ` projections.orgs1.change_date,` +
+ ` projections.orgs1.resource_owner,` +
+ ` projections.orgs1.org_state,` +
+ ` projections.orgs1.sequence,` +
+ ` projections.orgs1.name,` +
+ ` projections.orgs1.primary_domain` +
+ ` FROM projections.orgs1` +
` AS OF SYSTEM TIME '-1 ms' `
prepareOrgQueryCols = []string{
"id",
@@ -65,8 +65,8 @@ var (
}
prepareOrgUniqueStmt = `SELECT COUNT(*) = 0` +
- ` FROM projections.orgs` +
- ` LEFT JOIN projections.org_domains2 ON projections.orgs.id = projections.org_domains2.org_id AND projections.orgs.instance_id = projections.org_domains2.instance_id` +
+ ` FROM projections.orgs1` +
+ ` LEFT JOIN projections.org_domains2 ON projections.orgs1.id = projections.org_domains2.org_id AND projections.orgs1.instance_id = projections.org_domains2.instance_id` +
` AS OF SYSTEM TIME '-1 ms' `
prepareOrgUniqueCols = []string{
"count",
diff --git a/internal/query/project_grant_test.go b/internal/query/project_grant_test.go
index b504cf1fb4..fbb3432b6a 100644
--- a/internal/query/project_grant_test.go
+++ b/internal/query/project_grant_test.go
@@ -29,8 +29,8 @@ var (
` COUNT(*) OVER () ` +
` FROM projections.project_grants3 ` +
` LEFT JOIN projections.projects3 ON projections.project_grants3.project_id = projections.projects3.id AND projections.project_grants3.instance_id = projections.projects3.instance_id ` +
- ` LEFT JOIN projections.orgs AS r ON projections.project_grants3.resource_owner = r.id AND projections.project_grants3.instance_id = r.instance_id` +
- ` LEFT JOIN projections.orgs AS o ON projections.project_grants3.granted_org_id = o.id AND projections.project_grants3.instance_id = o.instance_id` +
+ ` LEFT JOIN projections.orgs1 AS r ON projections.project_grants3.resource_owner = r.id AND projections.project_grants3.instance_id = r.instance_id` +
+ ` LEFT JOIN projections.orgs1 AS o ON projections.project_grants3.granted_org_id = o.id AND projections.project_grants3.instance_id = o.instance_id` +
` AS OF SYSTEM TIME '-1 ms'`
projectGrantsCols = []string{
"project_id",
@@ -61,8 +61,8 @@ var (
` r.name` +
` FROM projections.project_grants3 ` +
` LEFT JOIN projections.projects3 ON projections.project_grants3.project_id = projections.projects3.id AND projections.project_grants3.instance_id = projections.projects3.instance_id ` +
- ` LEFT JOIN projections.orgs AS r ON projections.project_grants3.resource_owner = r.id AND projections.project_grants3.instance_id = r.instance_id` +
- ` LEFT JOIN projections.orgs AS o ON projections.project_grants3.granted_org_id = o.id AND projections.project_grants3.instance_id = o.instance_id` +
+ ` LEFT JOIN projections.orgs1 AS r ON projections.project_grants3.resource_owner = r.id AND projections.project_grants3.instance_id = r.instance_id` +
+ ` LEFT JOIN projections.orgs1 AS o ON projections.project_grants3.granted_org_id = o.id AND projections.project_grants3.instance_id = o.instance_id` +
` AS OF SYSTEM TIME '-1 ms'`
projectGrantCols = []string{
"project_id",
diff --git a/internal/query/projection/action.go b/internal/query/projection/action.go
index a687bad50f..780aee2d90 100644
--- a/internal/query/projection/action.go
+++ b/internal/query/projection/action.go
@@ -220,13 +220,8 @@ func (p *actionProjection) reduceOwnerRemoved(event eventstore.Event) (*handler.
if !ok {
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-mSmWM", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(ActionChangeDateCol, e.CreationDate()),
- handler.NewCol(ActionSequenceCol, e.Sequence()),
- handler.NewCol(ActionOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(ActionInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(ActionResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/action_test.go b/internal/query/projection/action_test.go
index b93875b4bb..2c235281ea 100644
--- a/internal/query/projection/action_test.go
+++ b/internal/query/projection/action_test.go
@@ -195,11 +195,8 @@ func TestActionProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.actions3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.actions3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/app.go b/internal/query/projection/app.go
index 483764d5d5..8ac53c10ba 100644
--- a/internal/query/projection/app.go
+++ b/internal/query/projection/app.go
@@ -598,13 +598,8 @@ func (p *appProjection) reduceOwnerRemoved(event eventstore.Event) (*handler.Sta
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-Hyd1f", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(AppColumnChangeDate, e.CreationDate()),
- handler.NewCol(AppColumnSequence, e.Sequence()),
- handler.NewCol(AppColumnOwnerRemoved, true),
- },
[]handler.Condition{
handler.NewCond(AppColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(AppColumnResourceOwner, e.Aggregate().ID),
diff --git a/internal/query/projection/app_test.go b/internal/query/projection/app_test.go
index c605ed6dc4..fe63c29919 100644
--- a/internal/query/projection/app_test.go
+++ b/internal/query/projection/app_test.go
@@ -629,11 +629,8 @@ func TestAppProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.apps5 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.apps5 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/authn_key.go b/internal/query/projection/authn_key.go
index 8288756612..789fb7edf9 100644
--- a/internal/query/projection/authn_key.go
+++ b/internal/query/projection/authn_key.go
@@ -256,13 +256,8 @@ func (p *authNKeyProjection) reduceOwnerRemoved(event eventstore.Event) (*handle
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-Hyd1f", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(AuthNKeyChangeDateCol, e.CreationDate()),
- handler.NewCol(AuthNKeySequenceCol, e.Sequence()),
- handler.NewCol(AuthNKeyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(AuthNKeyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(AuthNKeyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/authn_key_test.go b/internal/query/projection/authn_key_test.go
index f75b2590bb..c1341fb647 100644
--- a/internal/query/projection/authn_key_test.go
+++ b/internal/query/projection/authn_key_test.go
@@ -488,11 +488,8 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.authn_keys2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.authn_keys2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/custom_text.go b/internal/query/projection/custom_text.go
index 56e21e2b3f..b2e3650c46 100644
--- a/internal/query/projection/custom_text.go
+++ b/internal/query/projection/custom_text.go
@@ -188,13 +188,8 @@ func (p *customTextProjection) reduceOwnerRemoved(event eventstore.Event) (*hand
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-V2T3z", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(CustomTextChangeDateCol, e.CreationDate()),
- handler.NewCol(CustomTextSequenceCol, e.Sequence()),
- handler.NewCol(CustomTextOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(CustomTextInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(CustomTextAggregateIDCol, e.Aggregate().ID),
diff --git a/internal/query/projection/custom_text_test.go b/internal/query/projection/custom_text_test.go
index faee39dd41..f6889cf40e 100644
--- a/internal/query/projection/custom_text_test.go
+++ b/internal/query/projection/custom_text_test.go
@@ -278,11 +278,8 @@ func TestCustomTextProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.custom_texts2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (aggregate_id = $5)",
+ expectedStmt: "DELETE FROM projections.custom_texts2 WHERE (instance_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/domain_policy.go b/internal/query/projection/domain_policy.go
index dc192c58f5..97896edb98 100644
--- a/internal/query/projection/domain_policy.go
+++ b/internal/query/projection/domain_policy.go
@@ -185,13 +185,8 @@ func (p *domainPolicyProjection) reduceOwnerRemoved(event eventstore.Event) (*ha
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-JYD2K", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(DomainPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(DomainPolicySequenceCol, e.Sequence()),
- handler.NewCol(DomainPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(DomainPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(DomainPolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/domain_policy_test.go b/internal/query/projection/domain_policy_test.go
index 4823ff0f4b..7aa64999e6 100644
--- a/internal/query/projection/domain_policy_test.go
+++ b/internal/query/projection/domain_policy_test.go
@@ -244,11 +244,8 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.domain_policies2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.domain_policies2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/flow.go b/internal/query/projection/flow.go
index 4b03d74515..62c6cb1584 100644
--- a/internal/query/projection/flow.go
+++ b/internal/query/projection/flow.go
@@ -135,13 +135,8 @@ func (p *flowProjection) reduceOwnerRemoved(event eventstore.Event) (*handler.St
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-Yd7WC", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(FlowChangeDateCol, e.CreationDate()),
- handler.NewCol(FlowSequenceCol, e.Sequence()),
- handler.NewCol(FlowOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(FlowInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(FlowResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/flow_test.go b/internal/query/projection/flow_test.go
index 3ebfb8de75..49b1b8d497 100644
--- a/internal/query/projection/flow_test.go
+++ b/internal/query/projection/flow_test.go
@@ -122,11 +122,8 @@ func TestFlowProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.flow_triggers2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.flow_triggers2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/idp.go b/internal/query/projection/idp.go
index 94c1c9798b..a355c7adc1 100644
--- a/internal/query/projection/idp.go
+++ b/internal/query/projection/idp.go
@@ -554,13 +554,8 @@ func (p *idpProjection) reduceOwnerRemoved(event eventstore.Event) (*handler.Sta
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-YsbQC", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(IDPChangeDateCol, e.CreationDate()),
- handler.NewCol(IDPSequenceCol, e.Sequence()),
- handler.NewCol(IDPOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(IDPInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(IDPResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/idp_login_policy_link.go b/internal/query/projection/idp_login_policy_link.go
index 62118106d8..34df691a46 100644
--- a/internal/query/projection/idp_login_policy_link.go
+++ b/internal/query/projection/idp_login_policy_link.go
@@ -259,13 +259,8 @@ func (p *idpLoginPolicyLinkProjection) reduceOwnerRemoved(event eventstore.Event
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-YbhOv", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(IDPLoginPolicyLinkChangeDateCol, e.CreationDate()),
- handler.NewCol(IDPLoginPolicyLinkSequenceCol, e.Sequence()),
- handler.NewCol(IDPLoginPolicyLinkOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(IDPLoginPolicyLinkInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(IDPLoginPolicyLinkResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/idp_login_policy_link_test.go b/internal/query/projection/idp_login_policy_link_test.go
index f3d02c4730..569f3746bf 100644
--- a/internal/query/projection/idp_login_policy_link_test.go
+++ b/internal/query/projection/idp_login_policy_link_test.go
@@ -406,11 +406,8 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.idp_login_policy_links5 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.idp_login_policy_links5 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/idp_template.go b/internal/query/projection/idp_template.go
index 98da2db463..9dc9ff6073 100644
--- a/internal/query/projection/idp_template.go
+++ b/internal/query/projection/idp_template.go
@@ -2034,13 +2034,8 @@ func (p *idpTemplateProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-Jp0D2K", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(IDPTemplateChangeDateCol, e.CreationDate()),
- handler.NewCol(IDPTemplateSequenceCol, e.Sequence()),
- handler.NewCol(IDPTemplateOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(IDPTemplateInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(IDPTemplateResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/idp_template_test.go b/internal/query/projection/idp_template_test.go
index fe5c255ea1..fd4eedf880 100644
--- a/internal/query/projection/idp_template_test.go
+++ b/internal/query/projection/idp_template_test.go
@@ -77,11 +77,8 @@ func TestIDPTemplateProjection_reducesRemove(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.idp_templates5 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.idp_templates5 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
@@ -2411,11 +2408,8 @@ func TestIDPTemplateProjection_reducesLDAP(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.idp_templates5 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.idp_templates5 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/idp_test.go b/internal/query/projection/idp_test.go
index 10bbe76164..54eda3b848 100644
--- a/internal/query/projection/idp_test.go
+++ b/internal/query/projection/idp_test.go
@@ -906,11 +906,8 @@ func TestIDPProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.idps3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.idps3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/idp_user_link.go b/internal/query/projection/idp_user_link.go
index ed47ff1de5..c4b15a36d7 100644
--- a/internal/query/projection/idp_user_link.go
+++ b/internal/query/projection/idp_user_link.go
@@ -171,13 +171,8 @@ func (p *idpUserLinkProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-PGiAY", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(IDPUserLinkChangeDateCol, e.CreationDate()),
- handler.NewCol(IDPUserLinkSequenceCol, e.Sequence()),
- handler.NewCol(IDPUserLinkOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(IDPUserLinkResourceOwnerCol, e.Aggregate().ID),
handler.NewCond(IDPUserLinkInstanceIDCol, e.Aggregate().InstanceID),
diff --git a/internal/query/projection/idp_user_link_test.go b/internal/query/projection/idp_user_link_test.go
index a343fe0b63..f518163e26 100644
--- a/internal/query/projection/idp_user_link_test.go
+++ b/internal/query/projection/idp_user_link_test.go
@@ -141,11 +141,8 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.idp_user_links3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (resource_owner = $4) AND (instance_id = $5)",
+ expectedStmt: "DELETE FROM projections.idp_user_links3 WHERE (resource_owner = $1) AND (instance_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"agg-id",
"instance-id",
},
diff --git a/internal/query/projection/instance_member_test.go b/internal/query/projection/instance_member_test.go
index 5f56c64fe2..33c277f6c4 100644
--- a/internal/query/projection/instance_member_test.go
+++ b/internal/query/projection/instance_member_test.go
@@ -215,11 +215,8 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.instance_members3 SET (change_date, sequence, user_owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.instance_members3 WHERE (instance_id = $1) AND (user_resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/label_policy.go b/internal/query/projection/label_policy.go
index e62c39b4c5..fb3cd221af 100644
--- a/internal/query/projection/label_policy.go
+++ b/internal/query/projection/label_policy.go
@@ -607,13 +607,8 @@ func (p *labelPolicyProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-Su6pX", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(LabelPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(LabelPolicySequenceCol, e.Sequence()),
- handler.NewCol(LabelPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(LabelPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(LabelPolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/label_policy_test.go b/internal/query/projection/label_policy_test.go
index 88a82ea0cd..c046bb01dd 100644
--- a/internal/query/projection/label_policy_test.go
+++ b/internal/query/projection/label_policy_test.go
@@ -1007,11 +1007,8 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.label_policies2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.label_policies2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/lockout_policy.go b/internal/query/projection/lockout_policy.go
index 025213381f..1a6f9f7a77 100644
--- a/internal/query/projection/lockout_policy.go
+++ b/internal/query/projection/lockout_policy.go
@@ -179,13 +179,8 @@ func (p *lockoutPolicyProjection) reduceOwnerRemoved(event eventstore.Event) (*h
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-IoW0x", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(LockoutPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(LockoutPolicySequenceCol, e.Sequence()),
- handler.NewCol(LockoutPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(LockoutPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(LockoutPolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/lockout_policy_test.go b/internal/query/projection/lockout_policy_test.go
index 1b853dfc6b..338f3a92a5 100644
--- a/internal/query/projection/lockout_policy_test.go
+++ b/internal/query/projection/lockout_policy_test.go
@@ -236,11 +236,8 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.lockout_policies2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.lockout_policies2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/login_name.go b/internal/query/projection/login_name.go
index 12aaeb2af8..2d21bdaff8 100644
--- a/internal/query/projection/login_name.go
+++ b/internal/query/projection/login_name.go
@@ -574,30 +574,21 @@ func (p *loginNameProjection) reduceOwnerRemoved(event eventstore.Event) (*handl
return crdb.NewMultiStatement(
event,
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(LoginNameDomainOwnerRemovedCol, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(LoginNameDomainInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(LoginNameDomainResourceOwnerCol, e.Aggregate().ID),
},
crdb.WithTableSuffix(loginNameDomainSuffix),
),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(LoginNamePoliciesOwnerRemovedCol, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(LoginNamePoliciesInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(LoginNamePoliciesResourceOwnerCol, e.Aggregate().ID),
},
crdb.WithTableSuffix(loginNamePolicySuffix),
),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(LoginNameUserOwnerRemovedCol, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(LoginNameUserInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(LoginNameUserResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/login_name_test.go b/internal/query/projection/login_name_test.go
index 3364fcb1d7..92f1b583de 100644
--- a/internal/query/projection/login_name_test.go
+++ b/internal/query/projection/login_name_test.go
@@ -544,25 +544,22 @@ func TestLoginNameProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.login_names2_domains SET owner_removed = $1 WHERE (instance_id = $2) AND (resource_owner = $3)",
+ expectedStmt: "DELETE FROM projections.login_names2_domains WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.login_names2_policies SET owner_removed = $1 WHERE (instance_id = $2) AND (resource_owner = $3)",
+ expectedStmt: "DELETE FROM projections.login_names2_policies WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.login_names2_users SET owner_removed = $1 WHERE (instance_id = $2) AND (resource_owner = $3)",
+ expectedStmt: "DELETE FROM projections.login_names2_users WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/login_policy.go b/internal/query/projection/login_policy.go
index 856d02a464..f05dce5260 100644
--- a/internal/query/projection/login_policy.go
+++ b/internal/query/projection/login_policy.go
@@ -401,13 +401,8 @@ func (p *loginPolicyProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-B8NZW", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(LoginPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(LoginPolicySequenceCol, e.Sequence()),
- handler.NewCol(LoginPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(LoginPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(LoginPolicyIDCol, e.Aggregate().ID),
diff --git a/internal/query/projection/login_policy_test.go b/internal/query/projection/login_policy_test.go
index b475fa2a28..62df313b71 100644
--- a/internal/query/projection/login_policy_test.go
+++ b/internal/query/projection/login_policy_test.go
@@ -702,11 +702,8 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.login_policies5 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (aggregate_id = $5)",
+ expectedStmt: "DELETE FROM projections.login_policies5 WHERE (instance_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/mail_template.go b/internal/query/projection/mail_template.go
index 8153ffceb4..d88f000543 100644
--- a/internal/query/projection/mail_template.go
+++ b/internal/query/projection/mail_template.go
@@ -170,13 +170,8 @@ func (p *mailTemplateProjection) reduceOwnerRemoved(event eventstore.Event) (*ha
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-CThXR", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(MailTemplateChangeDateCol, e.CreationDate()),
- handler.NewCol(MailTemplateSequenceCol, e.Sequence()),
- handler.NewCol(MailTemplateOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(MailTemplateInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(MailTemplateAggregateIDCol, e.Aggregate().ID),
diff --git a/internal/query/projection/mail_template_test.go b/internal/query/projection/mail_template_test.go
index 284a75b154..f4a7d46b0d 100644
--- a/internal/query/projection/mail_template_test.go
+++ b/internal/query/projection/mail_template_test.go
@@ -226,11 +226,8 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.mail_templates2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (aggregate_id = $5)",
+ expectedStmt: "DELETE FROM projections.mail_templates2 WHERE (instance_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/member.go b/internal/query/projection/member.go
index b6cad5098b..3c6f0af184 100644
--- a/internal/query/projection/member.go
+++ b/internal/query/projection/member.go
@@ -139,12 +139,8 @@ func multiReduceMemberOwnerRemoved(e eventstore.Event, opts ...reduceMemberOpt)
for _, opt := range opts {
config = opt(config)
}
- return crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(MemberChangeDate, e.CreationDate()),
- handler.NewCol(MemberSequence, e.Sequence()),
- handler.NewCol(MemberOwnerRemoved, true),
- },
+
+ return crdb.AddDeleteStatement(
config.conds,
)
}
@@ -172,16 +168,14 @@ func memberUserOwnerRemovedCols(e eventstore.Event) []handler.Column {
}
func reduceMemberUserOwnerRemoved(e eventstore.Event, opts ...reduceMemberOpt) (*handler.Statement, error) {
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- memberUserOwnerRemovedCols(e),
memberUserOwnerRemovedConds(e, opts...),
), nil
}
func multiReduceMemberUserOwnerRemoved(e eventstore.Event, opts ...reduceMemberOpt) func(eventstore.Event) crdb.Exec {
- return crdb.AddUpdateStatement(
- memberUserOwnerRemovedCols(e),
+ return crdb.AddDeleteStatement(
memberUserOwnerRemovedConds(e, opts...),
)
}
diff --git a/internal/query/projection/message_text_test.go b/internal/query/projection/message_text_test.go
index b48dbed0fd..695829dde4 100644
--- a/internal/query/projection/message_text_test.go
+++ b/internal/query/projection/message_text_test.go
@@ -698,11 +698,8 @@ func TestMessageTextProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.message_texts2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (aggregate_id = $5)",
+ expectedStmt: "DELETE FROM projections.message_texts2 WHERE (instance_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/message_texts.go b/internal/query/projection/message_texts.go
index 40d6d5a505..43ede0d07f 100644
--- a/internal/query/projection/message_texts.go
+++ b/internal/query/projection/message_texts.go
@@ -253,13 +253,8 @@ func (p *messageTextProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-mLsQw", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(MessageTextChangeDateCol, e.CreationDate()),
- handler.NewCol(MessageTextSequenceCol, e.Sequence()),
- handler.NewCol(MessageTextOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(MessageTextInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(MessageTextAggregateIDCol, e.Aggregate().ID),
diff --git a/internal/query/projection/notification_policy.go b/internal/query/projection/notification_policy.go
index 628e322cc5..d064d4395a 100644
--- a/internal/query/projection/notification_policy.go
+++ b/internal/query/projection/notification_policy.go
@@ -172,13 +172,8 @@ func (p *notificationPolicyProjection) reduceOwnerRemoved(event eventstore.Event
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-poxi9a", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(DomainPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(DomainPolicySequenceCol, e.Sequence()),
- handler.NewCol(DomainPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(DomainPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(DomainPolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/notification_policy_test.go b/internal/query/projection/notification_policy_test.go
index 86a9ed1b65..b61fc6a440 100644
--- a/internal/query/projection/notification_policy_test.go
+++ b/internal/query/projection/notification_policy_test.go
@@ -227,11 +227,8 @@ func TestNotificationPolicyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.notification_policies SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.notification_policies WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/org.go b/internal/query/projection/org.go
index 1906b8977c..8ba5ae4960 100644
--- a/internal/query/projection/org.go
+++ b/internal/query/projection/org.go
@@ -13,7 +13,7 @@ import (
)
const (
- OrgProjectionTable = "projections.orgs"
+ OrgProjectionTable = "projections.orgs1"
OrgColumnID = "id"
OrgColumnCreationDate = "creation_date"
@@ -202,13 +202,8 @@ func (p *orgProjection) reduceOrgRemoved(event eventstore.Event) (*handler.State
if !ok {
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-DgMSg", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(OrgColumnChangeDate, e.CreationDate()),
- handler.NewCol(OrgColumnSequence, e.Sequence()),
- handler.NewCol(OrgColumnState, domain.OrgStateRemoved),
- },
[]handler.Condition{
handler.NewCond(OrgColumnID, e.Aggregate().ID),
handler.NewCond(OrgColumnInstanceID, e.Aggregate().InstanceID),
diff --git a/internal/query/projection/org_domain.go b/internal/query/projection/org_domain.go
index 3211cf7c2c..6436cab38d 100644
--- a/internal/query/projection/org_domain.go
+++ b/internal/query/projection/org_domain.go
@@ -215,13 +215,8 @@ func (p *orgDomainProjection) reduceOwnerRemoved(event eventstore.Event) (*handl
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-dMUKJ", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(OrgDomainChangeDateCol, e.CreationDate()),
- handler.NewCol(OrgDomainSequenceCol, e.Sequence()),
- handler.NewCol(OrgDomainOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(OrgDomainInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(OrgDomainOrgIDCol, e.Aggregate().ID),
diff --git a/internal/query/projection/org_domain_test.go b/internal/query/projection/org_domain_test.go
index 4c59cdcdef..99c265ecf0 100644
--- a/internal/query/projection/org_domain_test.go
+++ b/internal/query/projection/org_domain_test.go
@@ -205,11 +205,8 @@ func TestOrgDomainProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.org_domains2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (org_id = $5)",
+ expectedStmt: "DELETE FROM projections.org_domains2 WHERE (instance_id = $1) AND (org_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/org_member_test.go b/internal/query/projection/org_member_test.go
index b2066ab4c3..b9edf34ba0 100644
--- a/internal/query/projection/org_member_test.go
+++ b/internal/query/projection/org_member_test.go
@@ -218,21 +218,15 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.org_members3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.org_members3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.org_members3 SET (change_date, sequence, user_owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.org_members3 WHERE (instance_id = $1) AND (user_resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/org_test.go b/internal/query/projection/org_test.go
index bae5d6bec6..a5f6795fbc 100644
--- a/internal/query/projection/org_test.go
+++ b/internal/query/projection/org_test.go
@@ -39,7 +39,7 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, primary_domain) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
+ expectedStmt: "UPDATE projections.orgs1 SET (change_date, sequence, primary_domain) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
@@ -69,7 +69,7 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
+ expectedStmt: "UPDATE projections.orgs1 SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
@@ -99,7 +99,7 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
+ expectedStmt: "UPDATE projections.orgs1 SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
@@ -129,7 +129,7 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, name) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
+ expectedStmt: "UPDATE projections.orgs1 SET (change_date, sequence, name) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
@@ -176,7 +176,7 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "INSERT INTO projections.orgs (id, creation_date, change_date, resource_owner, instance_id, sequence, name, org_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
+ expectedStmt: "INSERT INTO projections.orgs1 (id, creation_date, change_date, resource_owner, instance_id, sequence, name, org_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
expectedArgs: []interface{}{
"agg-id",
anyArg{},
@@ -209,11 +209,8 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
+ expectedStmt: "DELETE FROM projections.orgs1 WHERE (id = $1) AND (instance_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- domain.OrgStateRemoved,
"agg-id",
"instance-id",
},
@@ -239,7 +236,7 @@ func TestOrgProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "DELETE FROM projections.orgs WHERE (instance_id = $1)",
+ expectedStmt: "DELETE FROM projections.orgs1 WHERE (instance_id = $1)",
expectedArgs: []interface{}{
"agg-id",
},
diff --git a/internal/query/projection/password_age_policy.go b/internal/query/projection/password_age_policy.go
index e8a2a3c958..f03ee0d553 100644
--- a/internal/query/projection/password_age_policy.go
+++ b/internal/query/projection/password_age_policy.go
@@ -179,13 +179,8 @@ func (p *passwordAgeProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-edLs2", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(AgePolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(AgePolicySequenceCol, e.Sequence()),
- handler.NewCol(AgePolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(AgePolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(AgePolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/password_age_policy_test.go b/internal/query/projection/password_age_policy_test.go
index baff9c2f3d..f6c5e801f9 100644
--- a/internal/query/projection/password_age_policy_test.go
+++ b/internal/query/projection/password_age_policy_test.go
@@ -236,11 +236,8 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.password_age_policies2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.password_age_policies2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/password_complexity_policy.go b/internal/query/projection/password_complexity_policy.go
index dde4f32ca8..b683cd556c 100644
--- a/internal/query/projection/password_complexity_policy.go
+++ b/internal/query/projection/password_complexity_policy.go
@@ -197,13 +197,8 @@ func (p *passwordComplexityProjection) reduceOwnerRemoved(event eventstore.Event
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-pGTz9", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(ComplexityPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(ComplexityPolicySequenceCol, e.Sequence()),
- handler.NewCol(ComplexityPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(ComplexityPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(ComplexityPolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/password_complexity_policy_test.go b/internal/query/projection/password_complexity_policy_test.go
index f9d2b1d836..ceac964704 100644
--- a/internal/query/projection/password_complexity_policy_test.go
+++ b/internal/query/projection/password_complexity_policy_test.go
@@ -260,11 +260,8 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.password_complexity_policies2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.password_complexity_policies2 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/privacy_policy.go b/internal/query/projection/privacy_policy.go
index 525363e42f..b577b5eff8 100644
--- a/internal/query/projection/privacy_policy.go
+++ b/internal/query/projection/privacy_policy.go
@@ -191,13 +191,8 @@ func (p *privacyPolicyProjection) reduceOwnerRemoved(event eventstore.Event) (*h
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-bxJCY", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(PrivacyPolicyChangeDateCol, e.CreationDate()),
- handler.NewCol(PrivacyPolicySequenceCol, e.Sequence()),
- handler.NewCol(PrivacyPolicyOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(PrivacyPolicyInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(PrivacyPolicyResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/privacy_policy_test.go b/internal/query/projection/privacy_policy_test.go
index f976c64e9b..630abc6f15 100644
--- a/internal/query/projection/privacy_policy_test.go
+++ b/internal/query/projection/privacy_policy_test.go
@@ -247,11 +247,8 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.privacy_policies3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.privacy_policies3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/project.go b/internal/query/projection/project.go
index c8f286f40a..0848cad6aa 100644
--- a/internal/query/projection/project.go
+++ b/internal/query/projection/project.go
@@ -231,13 +231,8 @@ func (p *projectProjection) reduceOwnerRemoved(event eventstore.Event) (*handler
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-sbgru", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(ProjectColumnChangeDate, e.CreationDate()),
- handler.NewCol(ProjectColumnSequence, e.Sequence()),
- handler.NewCol(ProjectColumnOwnerRemoved, true),
- },
[]handler.Condition{
handler.NewCond(ProjectColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(ProjectColumnResourceOwner, e.Aggregate().ID),
diff --git a/internal/query/projection/project_grant.go b/internal/query/projection/project_grant.go
index e68d2b6c0f..bb90298a17 100644
--- a/internal/query/projection/project_grant.go
+++ b/internal/query/projection/project_grant.go
@@ -260,23 +260,13 @@ func (p *projectGrantProjection) reduceOwnerRemoved(event eventstore.Event) (*ha
return crdb.NewMultiStatement(
e,
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(ProjectGrantColumnChangeDate, e.CreationDate()),
- handler.NewCol(ProjectGrantColumnSequence, e.Sequence()),
- handler.NewCol(ProjectGrantColumnOwnerRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(ProjectGrantColumnResourceOwner, e.Aggregate().ID),
},
),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(ProjectGrantColumnChangeDate, e.CreationDate()),
- handler.NewCol(ProjectGrantColumnSequence, e.Sequence()),
- handler.NewCol(ProjectGrantColumnGrantedOrgRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(ProjectGrantColumnGrantedOrgID, e.Aggregate().ID),
diff --git a/internal/query/projection/project_grant_member.go b/internal/query/projection/project_grant_member.go
index 06523df46f..596db4143f 100644
--- a/internal/query/projection/project_grant_member.go
+++ b/internal/query/projection/project_grant_member.go
@@ -196,12 +196,7 @@ func (p *projectGrantMemberProjection) reduceOrgRemoved(event eventstore.Event)
e,
multiReduceMemberOwnerRemoved(e),
multiReduceMemberUserOwnerRemoved(e),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(MemberChangeDate, e.CreationDate()),
- handler.NewCol(MemberSequence, e.Sequence()),
- handler.NewCol(ProjectGrantMemberGrantedOrgRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(ProjectGrantMemberGrantedOrg, e.Aggregate().ID),
diff --git a/internal/query/projection/project_grant_member_test.go b/internal/query/projection/project_grant_member_test.go
index 133c599264..12a032b9bc 100644
--- a/internal/query/projection/project_grant_member_test.go
+++ b/internal/query/projection/project_grant_member_test.go
@@ -313,31 +313,22 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.project_grant_members3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.project_grant_members3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.project_grant_members3 SET (change_date, sequence, user_owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.project_grant_members3 WHERE (instance_id = $1) AND (user_resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.project_grant_members3 SET (change_date, sequence, granted_org_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (granted_org = $5)",
+ expectedStmt: "DELETE FROM projections.project_grant_members3 WHERE (instance_id = $1) AND (granted_org = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/project_grant_test.go b/internal/query/projection/project_grant_test.go
index 0c4af2f093..c7ef0532d1 100644
--- a/internal/query/projection/project_grant_test.go
+++ b/internal/query/projection/project_grant_test.go
@@ -281,21 +281,15 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.project_grants3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.project_grants3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.project_grants3 SET (change_date, sequence, granted_org_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (granted_org_id = $5)",
+ expectedStmt: "DELETE FROM projections.project_grants3 WHERE (instance_id = $1) AND (granted_org_id = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/project_member_test.go b/internal/query/projection/project_member_test.go
index 698cc34b1d..4c0f1ee0c9 100644
--- a/internal/query/projection/project_member_test.go
+++ b/internal/query/projection/project_member_test.go
@@ -272,21 +272,15 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.project_members3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.project_members3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.project_members3 SET (change_date, sequence, user_owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.project_members3 WHERE (instance_id = $1) AND (user_resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/project_role.go b/internal/query/projection/project_role.go
index 5ee96e9e73..4287414f28 100644
--- a/internal/query/projection/project_role.go
+++ b/internal/query/projection/project_role.go
@@ -184,13 +184,8 @@ func (p *projectRoleProjection) reduceOwnerRemoved(event eventstore.Event) (*han
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-3XrHY", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(ProjectRoleColumnChangeDate, e.CreationDate()),
- handler.NewCol(ProjectRoleColumnSequence, e.Sequence()),
- handler.NewCol(ProjectRoleColumnOwnerRemoved, true),
- },
[]handler.Condition{
handler.NewCond(ProjectRoleColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(ProjectRoleColumnResourceOwner, e.Aggregate().ID),
diff --git a/internal/query/projection/project_role_test.go b/internal/query/projection/project_role_test.go
index 201c73e686..0f54eb34e0 100644
--- a/internal/query/projection/project_role_test.go
+++ b/internal/query/projection/project_role_test.go
@@ -203,11 +203,8 @@ func TestProjectRoleProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.project_roles3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.project_roles3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/project_test.go b/internal/query/projection/project_test.go
index 3ad1f18e09..a9c05d88c0 100644
--- a/internal/query/projection/project_test.go
+++ b/internal/query/projection/project_test.go
@@ -241,11 +241,8 @@ func TestProjectProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.projects3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.projects3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/user.go b/internal/query/projection/user.go
index 64500fa297..e67d992cda 100644
--- a/internal/query/projection/user.go
+++ b/internal/query/projection/user.go
@@ -1064,13 +1064,8 @@ func (p *userProjection) reduceOwnerRemoved(event eventstore.Event) (*handler.St
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-NCsdV", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(UserChangeDateCol, e.CreationDate()),
- handler.NewCol(UserSequenceCol, e.Sequence()),
- handler.NewCol(UserOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(UserInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(UserResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/user_auth_method.go b/internal/query/projection/user_auth_method.go
index 13b9c6db79..7e40fcb903 100644
--- a/internal/query/projection/user_auth_method.go
+++ b/internal/query/projection/user_auth_method.go
@@ -298,13 +298,8 @@ func (p *userAuthMethodProjection) reduceOwnerRemoved(event eventstore.Event) (*
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-FwDZ8", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(UserAuthMethodChangeDateCol, e.CreationDate()),
- handler.NewCol(UserAuthMethodSequenceCol, e.Sequence()),
- handler.NewCol(UserAuthMethodOwnerRemovedCol, true),
- },
[]handler.Condition{
handler.NewCond(UserAuthMethodInstanceIDCol, e.Aggregate().InstanceID),
handler.NewCond(UserAuthMethodResourceOwnerCol, e.Aggregate().ID),
diff --git a/internal/query/projection/user_auth_method_test.go b/internal/query/projection/user_auth_method_test.go
index 632f12ae92..6808d62afc 100644
--- a/internal/query/projection/user_auth_method_test.go
+++ b/internal/query/projection/user_auth_method_test.go
@@ -509,11 +509,8 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.user_auth_methods4 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.user_auth_methods4 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/user_grant.go b/internal/query/projection/user_grant.go
index d074e16e7a..c02187771b 100644
--- a/internal/query/projection/user_grant.go
+++ b/internal/query/projection/user_grant.go
@@ -396,45 +396,25 @@ func (p *userGrantProjection) reduceOwnerRemoved(event eventstore.Event) (*handl
return crdb.NewMultiStatement(
e,
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(UserGrantChangeDate, e.CreationDate()),
- handler.NewCol(UserGrantSequence, e.Sequence()),
- handler.NewCol(UserGrantOwnerRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(UserGrantInstanceID, e.Aggregate().InstanceID),
handler.NewCond(UserGrantResourceOwner, e.Aggregate().ID),
},
),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(UserGrantChangeDate, e.CreationDate()),
- handler.NewCol(UserGrantSequence, e.Sequence()),
- handler.NewCol(UserGrantUserOwnerRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(UserGrantInstanceID, e.Aggregate().InstanceID),
handler.NewCond(UserGrantResourceOwnerUser, e.Aggregate().ID),
},
),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(UserGrantChangeDate, e.CreationDate()),
- handler.NewCol(UserGrantSequence, e.Sequence()),
- handler.NewCol(UserGrantProjectOwnerRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(UserGrantInstanceID, e.Aggregate().InstanceID),
handler.NewCond(UserGrantResourceOwnerProject, e.Aggregate().ID),
},
),
- crdb.AddUpdateStatement(
- []handler.Column{
- handler.NewCol(UserGrantChangeDate, e.CreationDate()),
- handler.NewCol(UserGrantSequence, e.Sequence()),
- handler.NewCol(UserGrantGrantedOrgRemoved, true),
- },
+ crdb.AddDeleteStatement(
[]handler.Condition{
handler.NewCond(UserGrantInstanceID, e.Aggregate().InstanceID),
handler.NewCond(UserGrantGrantedOrg, e.Aggregate().ID),
diff --git a/internal/query/projection/user_grant_test.go b/internal/query/projection/user_grant_test.go
index a3e1c49079..a2f98f4bb7 100644
--- a/internal/query/projection/user_grant_test.go
+++ b/internal/query/projection/user_grant_test.go
@@ -517,41 +517,29 @@ func TestUserGrantProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.user_grants3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.user_grants3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.user_grants3 SET (change_date, sequence, user_owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner_user = $5)",
+ expectedStmt: "DELETE FROM projections.user_grants3 WHERE (instance_id = $1) AND (resource_owner_user = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.user_grants3 SET (change_date, sequence, project_owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner_project = $5)",
+ expectedStmt: "DELETE FROM projections.user_grants3 WHERE (instance_id = $1) AND (resource_owner_project = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
},
{
- expectedStmt: "UPDATE projections.user_grants3 SET (change_date, sequence, granted_org_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (granted_org = $5)",
+ expectedStmt: "DELETE FROM projections.user_grants3 WHERE (instance_id = $1) AND (granted_org = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/user_metadata.go b/internal/query/projection/user_metadata.go
index b7513d2d07..d1b06e52ef 100644
--- a/internal/query/projection/user_metadata.go
+++ b/internal/query/projection/user_metadata.go
@@ -163,13 +163,8 @@ func (p *userMetadataProjection) reduceOwnerRemoved(event eventstore.Event) (*ha
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-oqwul", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(UserMetadataColumnChangeDate, e.CreationDate()),
- handler.NewCol(UserMetadataColumnSequence, e.Sequence()),
- handler.NewCol(UserMetadataColumnOwnerRemoved, true),
- },
[]handler.Condition{
handler.NewCond(UserMetadataColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(UserMetadataColumnResourceOwner, e.Aggregate().ID),
diff --git a/internal/query/projection/user_metadata_test.go b/internal/query/projection/user_metadata_test.go
index e115326f13..923614c41a 100644
--- a/internal/query/projection/user_metadata_test.go
+++ b/internal/query/projection/user_metadata_test.go
@@ -159,11 +159,8 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.user_metadata4 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.user_metadata4 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/user_personal_access_token.go b/internal/query/projection/user_personal_access_token.go
index e44624f725..7ab5e494bd 100644
--- a/internal/query/projection/user_personal_access_token.go
+++ b/internal/query/projection/user_personal_access_token.go
@@ -155,13 +155,8 @@ func (p *personalAccessTokenProjection) reduceOwnerRemoved(event eventstore.Even
return nil, errors.ThrowInvalidArgumentf(nil, "PROJE-zQVhl", "reduce.wrong.event.type %s", org.OrgRemovedEventType)
}
- return crdb.NewUpdateStatement(
+ return crdb.NewDeleteStatement(
e,
- []handler.Column{
- handler.NewCol(PersonalAccessTokenColumnChangeDate, e.CreationDate()),
- handler.NewCol(PersonalAccessTokenColumnSequence, e.Sequence()),
- handler.NewCol(PersonalAccessTokenColumnOwnerRemoved, true),
- },
[]handler.Condition{
handler.NewCond(PersonalAccessTokenColumnInstanceID, e.Aggregate().InstanceID),
handler.NewCond(PersonalAccessTokenColumnResourceOwner, e.Aggregate().ID),
diff --git a/internal/query/projection/user_personal_access_token_test.go b/internal/query/projection/user_personal_access_token_test.go
index 778e03d221..a07229d71e 100644
--- a/internal/query/projection/user_personal_access_token_test.go
+++ b/internal/query/projection/user_personal_access_token_test.go
@@ -129,11 +129,8 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.personal_access_tokens3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.personal_access_tokens3 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/projection/user_test.go b/internal/query/projection/user_test.go
index 53d1e81863..7651e75d5c 100644
--- a/internal/query/projection/user_test.go
+++ b/internal/query/projection/user_test.go
@@ -1713,11 +1713,8 @@ func TestUserProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
- expectedStmt: "UPDATE projections.users8 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
+ expectedStmt: "DELETE FROM projections.users8 WHERE (instance_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{
- anyArg{},
- uint64(15),
- true,
"instance-id",
"agg-id",
},
diff --git a/internal/query/user_grant_test.go b/internal/query/user_grant_test.go
index da54f2008a..bcbd70b4c6 100644
--- a/internal/query/user_grant_test.go
+++ b/internal/query/user_grant_test.go
@@ -33,14 +33,14 @@ var (
", projections.users8_humans.avatar_key" +
", projections.login_names2.login_name" +
", projections.user_grants3.resource_owner" +
- ", projections.orgs.name" +
- ", projections.orgs.primary_domain" +
+ ", projections.orgs1.name" +
+ ", projections.orgs1.primary_domain" +
", 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.orgs ON projections.user_grants3.resource_owner = projections.orgs.id AND projections.user_grants3.instance_id = projections.orgs.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" +
` AS OF SYSTEM TIME '-1 ms' ` +
@@ -88,15 +88,15 @@ var (
", projections.users8_humans.avatar_key" +
", projections.login_names2.login_name" +
", projections.user_grants3.resource_owner" +
- ", projections.orgs.name" +
- ", projections.orgs.primary_domain" +
+ ", projections.orgs1.name" +
+ ", projections.orgs1.primary_domain" +
", projections.user_grants3.project_id" +
", 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.orgs ON projections.user_grants3.resource_owner = projections.orgs.id AND projections.user_grants3.instance_id = projections.orgs.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" +
` AS OF SYSTEM TIME '-1 ms' ` +
diff --git a/internal/query/user_membership_test.go b/internal/query/user_membership_test.go
index 237e21359d..108f5d8601 100644
--- a/internal/query/user_membership_test.go
+++ b/internal/query/user_membership_test.go
@@ -28,7 +28,7 @@ var (
", memberships.grant_id" +
", projections.project_grants3.granted_org_id" +
", projections.projects3.name" +
- ", projections.orgs.name" +
+ ", projections.orgs1.name" +
", COUNT(*) OVER ()" +
" FROM (" +
"SELECT members.user_id" +
@@ -88,7 +88,7 @@ var (
" WHERE members.granted_org_removed = $7 AND members.owner_removed = $8 AND members.user_owner_removed = $9" +
") AS memberships" +
" LEFT JOIN projections.projects3 ON memberships.project_id = projections.projects3.id AND memberships.instance_id = projections.projects3.instance_id" +
- " LEFT JOIN projections.orgs ON memberships.org_id = projections.orgs.id AND memberships.instance_id = projections.orgs.instance_id" +
+ " LEFT JOIN projections.orgs1 ON memberships.org_id = projections.orgs1.id AND memberships.instance_id = projections.orgs1.instance_id" +
" LEFT JOIN projections.project_grants3 ON memberships.grant_id = projections.project_grants3.grant_id AND memberships.instance_id = projections.project_grants3.instance_id" +
` AS OF SYSTEM TIME '-1 ms'`)
membershipCols = []string{
diff --git a/proto/zitadel/admin.proto b/proto/zitadel/admin.proto
index 99cf4893d0..760f270e6d 100644
--- a/proto/zitadel/admin.proto
+++ b/proto/zitadel/admin.proto
@@ -844,7 +844,7 @@ service AdminService {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Organizations";
summary: "Remove Organization";
- description: "Sets the state of the organization and all its resource (Users, Projects, Grants to and from the org) to remove. Users of this organization will not be able to log in."
+ description: "Deletes the organization and all its resources (Users, Projects, Grants to and from the org). Users of this organization will not be able to log in."
responses: {
key: "200";
value: {
diff --git a/proto/zitadel/management.proto b/proto/zitadel/management.proto
index 6561ff16ca..9f4675dee9 100644
--- a/proto/zitadel/management.proto
+++ b/proto/zitadel/management.proto
@@ -2027,7 +2027,7 @@ service ManagementService {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Organizations";
summary: "Delete Organization";
- description: "Sets the state of my organization and all its resource (Users, Projects, Grants to and from the org) to remove. Users of this organization will not be able to log in."
+ description: "Deletes my organization and all its resources (Users, Projects, Grants to and from the org). Users of this organization will not be able to log in."
parameters: {
headers: {
name: "x-zitadel-orgid";