Convert Data Storage to PostgreSQL Documents #74

Merged
danieljsummers merged 11 commits from pg-doc into main 2023-10-10 02:15:39 +00:00
3 changed files with 30 additions and 5 deletions
Showing only changes of commit 12041e03ff - Show all commits

View File

@ -1,9 +1,33 @@
open LiteDB open LiteDB
open MyPrayerJournal.Data
open MyPrayerJournal.Domain open MyPrayerJournal.Domain
open MyPrayerJournal.LiteData open MyPrayerJournal.LiteData
open Microsoft.Extensions.Configuration
let lite = new LiteDatabase "Filename=./mpj.db" let lite = new LiteDatabase "Filename=./mpj.db"
Startup.ensureDb lite Startup.ensureDb lite
let cfg = (ConfigurationBuilder().AddJsonFile "appsettings.json").Build ()
Connection.setUp cfg |> Async.AwaitTask |> Async.RunSynchronously
let reqs = lite.Requests.FindAll ()
reqs
|> Seq.map (fun old ->
{ Request.empty with
Id = old.Id
EnteredOn = old.EnteredOn
UserId = old.UserId
SnoozedUntil = old.SnoozedUntil
ShowAfter = old.ShowAfter
Recurrence = old.Recurrence
History = old.History |> Array.sortByDescending (fun it -> it.AsOf) |> List.ofArray
Notes = old.Notes |> Array.sortByDescending (fun it -> it.AsOf) |> List.ofArray
})
|> Seq.map Request.add
|> List.ofSeq
|> List.iter (Async.AwaitTask >> Async.RunSynchronously)
System.Console.WriteLine $"Migration complete - {Seq.length reqs} requests migrated"

View File

@ -36,7 +36,8 @@ module Json =
] ]
|> List.iter opts.Converters.Add |> List.iter opts.Converters.Add
let _ = opts.ConfigureForNodaTime NodaTime.DateTimeZoneProviders.Tzdb let _ = opts.ConfigureForNodaTime NodaTime.DateTimeZoneProviders.Tzdb
opts.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase opts.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
opts.DefaultIgnoreCondition <- JsonIgnoreCondition.WhenWritingNull
opts opts
@ -165,9 +166,9 @@ module Journal =
return return
reqs reqs
|> Seq.ofList |> Seq.ofList
|> Seq.map JournalRequest.ofRequestFull |> Seq.map JournalRequest.ofRequestLite
|> Seq.filter (fun it -> it.LastStatus = Answered) |> Seq.filter (fun it -> it.LastStatus <> Answered)
|> Seq.sortByDescending (fun it -> it.AsOf) |> Seq.sortBy (fun it -> it.AsOf)
|> List.ofSeq |> List.ofSeq
} }

View File

@ -1,6 +1,6 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"db": "Filename=./mpj.db" "mpj": "host=localhost;username=mpj;password=devpassword;database=mpj"
}, },
"Kestrel": { "Kestrel": {
"EndPoints": { "EndPoints": {