|
@@ -0,0 +1,41 @@
|
|
|
+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.Database_Update_Scripts;
|
|
|
+
|
|
|
+/// <summary>
|
|
|
+/// Update all the documents to use external storage.
|
|
|
+/// </summary>
|
|
|
+internal class Update_7_54 : DatabaseUpdateScript
|
|
|
+{
|
|
|
+ public override VersionNumber Version => new(7, 54);
|
|
|
+
|
|
|
+ public override bool Update()
|
|
|
+ {
|
|
|
+ var store = DbFactory.FindStore<Document>(Guid.Empty, "", Platform.Server, CoreUtils.GetVersion());
|
|
|
+ int i = 0;
|
|
|
+ int numStep = 100;
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ var documents = DbFactory.Provider.Query<Document>(
|
|
|
+ new Filter<Document>(x => x.Data).IsNotEqualTo(null)
|
|
|
+ .And(x => x.Data).IsNotEqualTo(Array.Empty<byte>()),
|
|
|
+ new Columns<Document>(x => x.ID).Add(x => x.Data),
|
|
|
+ top: numStep).ToObjects<Document>();
|
|
|
+ store.Save(documents, "");
|
|
|
+
|
|
|
+ i += numStep;
|
|
|
+
|
|
|
+ if (i / numStep % 10 == 0)
|
|
|
+ {
|
|
|
+ Logger.Send(LogType.Information, "", $"Converted {i} documents");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|