fix: fix and improve primary keys on projections (#3708)

* fix: org_domain projection

* fix: projection reset

* fix test

* improve foreign keys on suffixed tables
This commit is contained in:
Livio Amstutz
2022-05-25 14:15:13 +02:00
committed by GitHub
parent 79452da7d6
commit 737e01bfd2
20 changed files with 403 additions and 156 deletions

View File

@@ -35,7 +35,7 @@ func NewSMTPConfigProjection(ctx context.Context, config crdb.StatementHandlerCo
p := new(SMTPConfigProjection)
config.ProjectionName = SMTPConfigProjectionTable
config.Reducers = p.reducers()
config.InitCheck = crdb.NewMultiTableCheck(
config.InitCheck = crdb.NewTableCheck(
crdb.NewTable([]*crdb.Column{
crdb.NewColumn(SMTPConfigColumnAggregateID, crdb.ColumnTypeText),
crdb.NewColumn(SMTPConfigColumnCreationDate, crdb.ColumnTypeTimestamp),
@@ -132,6 +132,7 @@ func (p *SMTPConfigProjection) reduceSMTPConfigChanged(event eventstore.Event) (
columns,
[]handler.Condition{
handler.NewCond(SMTPConfigColumnAggregateID, e.Aggregate().ID),
handler.NewCond(SMTPConfigColumnInstanceID, e.Aggregate().InstanceID),
},
), nil
}
@@ -151,6 +152,7 @@ func (p *SMTPConfigProjection) reduceSMTPConfigPasswordChanged(event eventstore.
},
[]handler.Condition{
handler.NewCond(SMTPConfigColumnAggregateID, e.Aggregate().ID),
handler.NewCond(SMTPConfigColumnInstanceID, e.Aggregate().InstanceID),
},
), nil
}