Cover re-type alterations by creating additional columns
This commit is contained in:
@@ -623,7 +623,7 @@ func (svc module) updater(ctx context.Context, namespaceID, moduleID uint64, act
|
||||
if err = svc.eventbus.WaitFor(ctx, event.ModuleAfterUpdate(m, old, ns)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = DalModelReplace(ctx, s, svc.schemaAltManager, svc.dal, ns, old, m); err != nil {
|
||||
if err = DalModelReplace(ctx, s, svc.schemaAltManager, svc.dal, ns, m); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -513,9 +513,23 @@ func (c *connection) assertAlterationAttributeReType(table *ddl.Table, colIndex
|
||||
return
|
||||
}
|
||||
|
||||
// @todo might consider droppig this one for now
|
||||
// @todo for now it just creates a new column; we should add some migration in the future
|
||||
func (c *connection) assertAlterationAttributeReEncode(table *ddl.Table, colIndex map[string]*ddl.Column, alt *dal.Alteration) (out []*dal.Alteration, err error) {
|
||||
// ...
|
||||
auxCodec := *alt.AttributeReEncode.Attr
|
||||
auxCodec.Store = alt.AttributeReEncode.To
|
||||
|
||||
out = append(out, &dal.Alteration{
|
||||
ID: alt.ID,
|
||||
BatchID: alt.BatchID,
|
||||
DependsOn: alt.DependsOn,
|
||||
Resource: alt.Resource,
|
||||
ResourceType: alt.ResourceType,
|
||||
ConnectionID: alt.ConnectionID,
|
||||
|
||||
AttributeAdd: &dal.AttributeAdd{
|
||||
Attr: &auxCodec,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user