using InABox.Configuration; using InABox.Core; using InABox.Database; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PRS.Shared { public class Update_7_43 : DatabaseUpdateScript { public override VersionNumber Version => new VersionNumber(7, 43); public override bool Update() { var filters = DbFactory.Provider.Query( new InABox.Core.Filter(x => x.Section).IsEqualTo("CoreFilterDefinitions"), new InABox.Core.Columns(x => x.ID, x => x.Contents)).ToObjects().ToList(); foreach(var filter in filters) { var defs = Serialization.Deserialize(filter.Contents) ?? new CoreFilterDefinitions(); var nextSequence = 0L; foreach(var def in defs) { if(def.Sequence < nextSequence) { def.Sequence = nextSequence; } nextSequence = def.Sequence + 1; } filter.Contents = Serialization.Serialize(defs); } DbFactory.Provider.Save(filters); return true; } } }