From babc77bbd03ee8cfa3a89bd29031989f659b6e41 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 26 Oct 2021 19:50:51 -0400 Subject: [PATCH] Remove v2/v3 migration project --- src/MyPrayerJournal.Migrate/Migrate.fsproj | 22 --------- src/MyPrayerJournal.Migrate/Program.fs | 57 ---------------------- 2 files changed, 79 deletions(-) delete mode 100644 src/MyPrayerJournal.Migrate/Migrate.fsproj delete mode 100644 src/MyPrayerJournal.Migrate/Program.fs diff --git a/src/MyPrayerJournal.Migrate/Migrate.fsproj b/src/MyPrayerJournal.Migrate/Migrate.fsproj deleted file mode 100644 index d228dd8..0000000 --- a/src/MyPrayerJournal.Migrate/Migrate.fsproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - Exe - net6.0 - - - - - - - - - - - - - - - - - diff --git a/src/MyPrayerJournal.Migrate/Program.fs b/src/MyPrayerJournal.Migrate/Program.fs deleted file mode 100644 index 49780c5..0000000 --- a/src/MyPrayerJournal.Migrate/Program.fs +++ /dev/null @@ -1,57 +0,0 @@ -open FSharp.Data -open FSharp.Data.CsvExtensions -open LiteDB -open MyPrayerJournal.Domain -open NodaTime - -module Subdocs = - - open FSharp.Data.JsonExtensions - - let history json = - match JsonValue.Parse json with - | JsonValue.Array hist -> - hist - |> Array.map (fun h -> - { asOf = (h?asOf.AsInteger64 >> Instant.FromUnixTimeMilliseconds) () - status = h?status.AsString () |> RequestAction.ofString - text = match h?text.AsString () with "" -> None | txt -> Some txt - }) - |> List.ofArray - | _ -> [] - - let notes json = - match JsonValue.Parse json with - | JsonValue.Array notes -> - notes - |> Array.map (fun n -> - { asOf = (n?asOf.AsInteger64 >> Instant.FromUnixTimeMilliseconds) () - notes = n?notes.AsString () - }) - |> List.ofArray - | _ -> [] - -let oldData = CsvFile.Load("data.csv") - -let db = new LiteDatabase("Filename=./mpj.db") - -MyPrayerJournal.Data.Startup.ensureDb db - -let migrated = - oldData.Rows - |> Seq.map (fun r -> - { id = r["@id"].Replace ("Requests/", "") |> RequestId.ofString - enteredOn = (r?enteredOn.AsInteger64 >> Instant.FromUnixTimeMilliseconds) () - userId = UserId r?userId - snoozedUntil = (r?snoozedUntil.AsInteger64 >> Instant.FromUnixTimeMilliseconds) () - showAfter = (r?showAfter.AsInteger64 >> Instant.FromUnixTimeMilliseconds) () - recurType = r?recurType |> Recurrence.ofString - recurCount = (r?recurCount.AsInteger >> int16) () - history = Subdocs.history r?history - notes = Subdocs.notes r?notes - }) - |> db.GetCollection("request").Insert - -db.Checkpoint () - -printfn $"Migrated {migrated} requests"