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 5dafb0142..1672159ca 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 b3407a41f..298434676 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 daa3b704e..a2330d04a 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 9c8daa3c3..cba525624 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 5d12e9552..abb877423 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 c5a8f2b60..8cc362ffd 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 c1fc647d1..36cb26f7d 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 73d3cef81..0857b1b24 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 a29ec6ad9..ddc06cc51 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 3a3a5c211..a09aab1bc 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 83531c1ce..6cf1185fe 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 a73d77a27..142df950e 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 e67ba69dc..8696b3fb2 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 6ba4b54dc..e99878f63 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 c4c2c21ad..55e954629 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 b504cf1fb..fbb3432b6 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 a687bad50..780aee2d9 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 b93875b4b..2c235281e 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 483764d5d..8ac53c10b 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 c605ed6dc..fe63c2991 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 828875661..789fb7edf 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 f75b2590b..c1341fb64 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 56e21e2b3..b2e3650c4 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 faee39dd4..f6889cf40 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 dc192c58f..97896edb9 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 4823ff0f4..7aa64999e 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 4b03d7451..62c6cb158 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 3ebfb8de7..49b1b8d49 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 94c1c9798..a355c7adc 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 62118106d..34df691a4 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 f3d02c473..569f3746b 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 98da2db46..9dc9ff607 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 fe5c255ea..fd4eedf88 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 10bbe7616..54eda3b84 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 ed47ff1de..c4b15a36d 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 a343fe0b6..f518163e2 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 5f56c64fe..33c277f6c 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 e62c39b4c..fb3cd221a 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 88a82ea0c..c046bb01d 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 025213381..1a6f9f7a7 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 1b853dfc6..338f3a92a 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 12aaeb2af..2d21bdaff 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 3364fcb1d..92f1b583d 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 856d02a46..f05dce526 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 b475fa2a2..62df313b7 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 8153ffceb..d88f00054 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 284a75b15..f4a7d46b0 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 b6cad5098..3c6f0af18 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 b48dbed0f..695829dde 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 40d6d5a50..43ede0d07 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 628e322cc..d064d4395 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 86a9ed1b6..b61fc6a44 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 1906b8977..8ba5ae496 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 3211cf7c2..6436cab38 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 4c59cdcde..99c265ecf 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 b2066ab4c..b9edf34ba 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 bae5d6bec..a5f6795fb 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 e8a2a3c95..f03ee0d55 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 baff9c2f3..f6c5e801f 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 dde4f32ca..b683cd556 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 f9d2b1d83..ceac96470 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 525363e42..b577b5eff 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 f976c64e9..630abc6f1 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 c8f286f40..0848cad6a 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 e68d2b6c0..bb90298a1 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 06523df46..596db4143 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 133c59926..12a032b9b 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 0c4af2f09..c7ef0532d 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 698cc34b1..4c0f1ee0c 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 5ee96e9e7..4287414f2 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 201c73e68..0f54eb34e 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 3ad1f18e0..a9c05d88c 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 64500fa29..e67d992cd 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 13b9c6db7..7e40fcb90 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 632f12ae9..6808d62af 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 d074e16e7..c02187771 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 a3e1c4907..a2f98f4bb 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 b7513d2d0..d1b06e52e 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 e115326f1..923614c41 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 e44624f72..7ab5e494b 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 778e03d22..a07229d71 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 53d1e8186..7651e75d5 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 da54f2008..bcbd70b4c 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 237e21359..108f5d860 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 99cf4893d..760f270e6 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 6561ff16c..9f4675dee 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";