feat: migrate unique constraints v1 to v2 (#1274)

* fix: unique migration

* fix: unique migration

* fix: remove migrations

* fix: member events
This commit is contained in:
Fabi
2021-02-15 13:31:24 +01:00
committed by GitHub
parent 3bc3ef1f2c
commit ee86eb4399
47 changed files with 630 additions and 173 deletions
+9 -4
View File
@@ -70,7 +70,8 @@ func OrgAddedEventMapper(event *repository.Event) (eventstore.EventReader, error
type OrgChangedEvent struct {
eventstore.BaseEvent `json:"-"`
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
oldName string `json:"-"`
}
func (e *OrgChangedEvent) Data() interface{} {
@@ -78,16 +79,20 @@ func (e *OrgChangedEvent) Data() interface{} {
}
func (e *OrgChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
return []*eventstore.EventUniqueConstraint{
NewRemoveOrgDomainUniqueConstraint(e.oldName),
NewAddOrgNameUniqueConstraint(e.Name),
}
}
func NewOrgChangedEvent(ctx context.Context, name string) *OrgChangedEvent {
func NewOrgChangedEvent(ctx context.Context, oldName, newName string) *OrgChangedEvent {
return &OrgChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
OrgChangedEventType,
),
Name: name,
Name: newName,
oldName: oldName,
}
}