Cover re-type alterations by creating additional columns

This commit is contained in:
Tomaž Jerman
2023-12-13 10:17:12 +01:00
parent 33821ddd9f
commit 4520742ad8
2 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -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 {
+16 -2
View File
@@ -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
}