Migrate data
This commit is contained in:
parent
399b15db9c
commit
12041e03ff
@ -1,9 +1,33 @@
|
||||
open LiteDB
|
||||
open MyPrayerJournal.Data
|
||||
open MyPrayerJournal.Domain
|
||||
open MyPrayerJournal.LiteData
|
||||
open Microsoft.Extensions.Configuration
|
||||
|
||||
|
||||
let lite = new LiteDatabase "Filename=./mpj.db"
|
||||
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"
|
||||
|
||||
|
@ -36,7 +36,8 @@ module Json =
|
||||
]
|
||||
|> List.iter opts.Converters.Add
|
||||
let _ = opts.ConfigureForNodaTime NodaTime.DateTimeZoneProviders.Tzdb
|
||||
opts.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
|
||||
opts.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
|
||||
opts.DefaultIgnoreCondition <- JsonIgnoreCondition.WhenWritingNull
|
||||
opts
|
||||
|
||||
|
||||
@ -165,9 +166,9 @@ module Journal =
|
||||
return
|
||||
reqs
|
||||
|> Seq.ofList
|
||||
|> Seq.map JournalRequest.ofRequestFull
|
||||
|> Seq.filter (fun it -> it.LastStatus = Answered)
|
||||
|> Seq.sortByDescending (fun it -> it.AsOf)
|
||||
|> Seq.map JournalRequest.ofRequestLite
|
||||
|> Seq.filter (fun it -> it.LastStatus <> Answered)
|
||||
|> Seq.sortBy (fun it -> it.AsOf)
|
||||
|> List.ofSeq
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"db": "Filename=./mpj.db"
|
||||
"mpj": "host=localhost;username=mpj;password=devpassword;database=mpj"
|
||||
},
|
||||
"Kestrel": {
|
||||
"EndPoints": {
|
||||
|
Loading…
Reference in New Issue
Block a user