fix: add migration (#361)

* fix: add migration

* fix: add migration

* fix: delete primary domain

* Update en.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi 2020-07-07 14:23:09 +02:00 committed by GitHub
parent eaef079852
commit fb2091edc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 6 deletions

View File

@ -49,13 +49,13 @@ func (o *Org) IsValid() bool {
return o.Name != ""
}
func (o *Org) ContainsDomain(domain *OrgDomain) bool {
for _, d := range o.Domains {
func (o *Org) GetDomain(domain *OrgDomain) (int, *OrgDomain) {
for i, d := range o.Domains {
if d.Domain == domain.Domain {
return true
return i, d
}
}
return false
return -1, nil
}
func (o *Org) GetPrimaryDomain() *OrgDomain {

View File

@ -179,9 +179,13 @@ func (es *OrgEventstore) RemoveOrgDomain(ctx context.Context, domain *org_model.
if err != nil {
return err
}
if !existing.ContainsDomain(domain) {
_, d := existing.GetDomain(domain)
if d == nil {
return errors.ThrowPreconditionFailed(nil, "EVENT-Sjdi3", "Errors.Org.DomainNotOnOrg")
}
if d.Primary {
return errors.ThrowPreconditionFailed(nil, "EVENT-Sjdi3", "Errors.Org.PrimaryDomainNotDeletable")
}
repoOrg := model.OrgFromModel(existing)
repoDomain := model.OrgDomainFromModel(domain)
orgAggregates, err := OrgDomainRemovedAggregate(ctx, es.Eventstore.AggregateCreator(), repoOrg, repoDomain)

View File

@ -54,6 +54,7 @@ Errors:
InvalidDomain: Domäne ist ungültig
DomainMissing: Domäne fehlt
DomainNotOnOrg: Domäne fehlt auf Organisation
PrimaryDomainNotDeletable: Primäre Domäne kann nicht gelöscht werden
DomainNotFound: Domäne konnte nicht gefunden werden
MemberIDMissing: Member ID fehlt
MemberNotFound: Organisations Member konnte nicht gefunden werden

View File

@ -54,6 +54,7 @@ Errors:
InvalidDomain: Invalid domain
DomainMissing: Domain missing
DomainNotOnOrg: Domain doesn't exist on organisation
PrimaryDomainNotDeletable: Primary domain must not be deleted
DomainNotFound: Domain not found
MemberIDMissing: Member ID missing
MemberNotFound: Organisations member not found
@ -113,4 +114,4 @@ Errors:
Token:
NotFound: Token not found
UserSession:
NotFound: UserSession not found
NotFound: UserSession not found

View File

@ -0,0 +1,2 @@
GRANT DROP ON DATABASE admin_api TO admin_api;
GRANT DROP ON TABLE admin_api.* TO admin_api;