Allow alterations for default schema but prevent applying
This commit is contained in:
parent
0ece3b25d0
commit
b389d5039d
@ -831,6 +831,8 @@ func (svc *service) applyAlteration(ctx context.Context, alts ...*Alteration) (e
|
||||
}
|
||||
|
||||
var (
|
||||
c = svc.GetConnectionByID(0)
|
||||
|
||||
connectionID = alts[0].ConnectionID
|
||||
resource = alts[0].Resource
|
||||
resourceType = alts[0].ResourceType
|
||||
@ -864,6 +866,11 @@ func (svc *service) applyAlteration(ctx context.Context, alts ...*Alteration) (e
|
||||
return nil, fmt.Errorf("model not found")
|
||||
}
|
||||
|
||||
if model.ConnectionID == c.ID && model.Ident == "compose_record" {
|
||||
err = fmt.Errorf("cannot apply alterations for default schema")
|
||||
return
|
||||
}
|
||||
|
||||
issues = issues.addModel(model.ResourceID)
|
||||
|
||||
// @todo consider adding some logging to validators
|
||||
|
||||
@ -149,15 +149,6 @@ func (svc dalSchemaAlteration) SetAlterations(ctx context.Context, s store.Store
|
||||
u = intAuth.GetIdentityFromContext(ctx).Identity()
|
||||
)
|
||||
|
||||
// @todo this won't work entirely; if someone defines a dal connection to the same DSN as the primary one,
|
||||
// they can easily bypass this.
|
||||
// We'll need to do some checking on the DSN; potentially when defining the connection itself.
|
||||
c := svc.dal.GetConnectionByID(0)
|
||||
if m.ConnectionID == c.ID && m.Ident == "compose_record" {
|
||||
err = fmt.Errorf("cannot set alterations for default schema")
|
||||
return
|
||||
}
|
||||
|
||||
// Delete current ones
|
||||
// @todo we might be able to do some diffing to preserve the metadata/ids
|
||||
// but for now this should be just fine.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user