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,10 +87,15 @@ 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
| 4 ->
let clientCert = new X509Certificate2 (argv.[1], argv.[2])
let raven = new DocumentStore (Urls = [| argv.[0] |], Database = "myPrayerJournal", Certificate = clientCert)
raven.Conventions.CustomizeJsonSerializer <- raven.Conventions.CustomizeJsonSerializer <-
fun x -> fun x ->
x.Converters.Add (RequestIdJsonConverter ()) x.Converters.Add (RequestIdJsonConverter ())
@ -92,6 +103,8 @@ let main argv =
x.Converters.Add (UserIdJsonConverter ()) x.Converters.Add (UserIdJsonConverter ())
x.Converters.Add (CompactUnionJsonConverter ()) x.Converters.Add (CompactUnionJsonConverter ())
let store = raven.Initialize () let store = raven.Initialize ()
migrateRequests store argv.[1] migrateRequests store argv.[3]
printfn "fin" printfn "fin"
0 // return an integer exit code | _ ->
Console.WriteLine "Usage: dotnet migrate.dll [raven-url] [raven-cert-file] [raven-cert-pw] [postgres-conn-str]"
0