myPrayerJournal v2 #27

Merged
danieljsummers merged 27 commits from version-2 into master 2019-09-03 00:01:26 +00:00
Showing only changes of commit f9d3b98c9e - Show all commits

View File

@ -66,7 +66,13 @@ let migrateRequests (store : IDocumentStore) connStr =
use rdr = cmd.ExecuteReader () use rdr = cmd.ExecuteReader ()
while rdr.Read () do while rdr.Read () do
let reqId = rdr.getString "requestId" let reqId = rdr.getString "requestId"
let recurrence = (rdr.getString >> Recurrence.fromString) "recurType" let recurrence =
match rdr.getString "recurType" with
| "immediate" -> Immediate
| "hours" -> Hours
| "days" -> Days
| "weeks" -> Weeks
| x -> invalidOp (sprintf "%s is not a valid recurrence" x)
sess.Store ( sess.Store (
{ Id = (RequestId.fromIdString >> RequestId.toString) reqId { Id = (RequestId.fromIdString >> RequestId.toString) reqId
enteredOn = rdr.getTicks "enteredOn" enteredOn = rdr.getTicks "enteredOn"
@ -81,17 +87,24 @@ let migrateRequests (store : IDocumentStore) connStr =
sess.SaveChanges () sess.SaveChanges ()
open Converters open Converters
open System
open System.Security.Cryptography.X509Certificates
[<EntryPoint>] [<EntryPoint>]
let main argv = let main argv =
let raven = new DocumentStore (Urls = [| argv.[0] |], Database = "myPrayerJournal") match argv.Length with
raven.Conventions.CustomizeJsonSerializer <- | 4 ->
fun x -> let clientCert = new X509Certificate2 (argv.[1], argv.[2])
x.Converters.Add (RequestIdJsonConverter ()) let raven = new DocumentStore (Urls = [| argv.[0] |], Database = "myPrayerJournal", Certificate = clientCert)
x.Converters.Add (TicksJsonConverter ()) raven.Conventions.CustomizeJsonSerializer <-
x.Converters.Add (UserIdJsonConverter ()) fun x ->
x.Converters.Add (CompactUnionJsonConverter ()) x.Converters.Add (RequestIdJsonConverter ())
let store = raven.Initialize () x.Converters.Add (TicksJsonConverter ())
migrateRequests store argv.[1] x.Converters.Add (UserIdJsonConverter ())
printfn "fin" x.Converters.Add (CompactUnionJsonConverter ())
0 // return an integer exit code let store = raven.Initialize ()
migrateRequests store argv.[3]
printfn "fin"
| _ ->
Console.WriteLine "Usage: dotnet migrate.dll [raven-url] [raven-cert-file] [raven-cert-pw] [postgres-conn-str]"
0