Version 2.1 #41
@ -14,11 +14,7 @@ type PostgresData(log: ILogger<PostgresData>, ser: JsonSerializer) =
|
||||
/// Create any needed tables
|
||||
let ensureTables () = backgroundTask {
|
||||
// Set up the PostgreSQL document store
|
||||
Configuration.useSerializer
|
||||
{ new IDocumentSerializer with
|
||||
member _.Serialize<'T>(it: 'T) : string = Utils.serialize ser it
|
||||
member _.Deserialize<'T>(it: string) : 'T = Utils.deserialize ser it
|
||||
}
|
||||
Configuration.useSerializer (Utils.createDocumentSerializer ser)
|
||||
|
||||
let! tables =
|
||||
Custom.list "SELECT tablename FROM pg_tables WHERE schemaname = 'public'" []
|
||||
|
@ -16,6 +16,8 @@ type SQLiteData(conn: SqliteConnection, log: ILogger<SQLiteData>, ser: JsonSeria
|
||||
/// Create tables (and their associated indexes) if they do not exist
|
||||
let ensureTables () = backgroundTask {
|
||||
|
||||
Configuration.useSerializer (Utils.createDocumentSerializer ser)
|
||||
|
||||
let! tables = conn.customList<string> "SELECT name FROM sqlite_master WHERE type = 'table'" [] _.GetString(0)
|
||||
|
||||
let needsTable table =
|
||||
|
@ -50,6 +50,16 @@ let serialize<'T> ser (item: 'T) =
|
||||
let deserialize<'T> (ser: JsonSerializer) value =
|
||||
JsonConvert.DeserializeObject<'T>(value, Json.settings ser)
|
||||
|
||||
open BitBadger.Documents
|
||||
|
||||
/// Create a document serializer using the given JsonSerializer
|
||||
let createDocumentSerializer ser =
|
||||
{ new IDocumentSerializer with
|
||||
member _.Serialize<'T>(it: 'T) : string = serialize ser it
|
||||
member _.Deserialize<'T>(it: string) : 'T = deserialize ser it
|
||||
}
|
||||
|
||||
|
||||
open Microsoft.Extensions.Logging
|
||||
|
||||
/// Log a migration step
|
||||
|
Loading…
Reference in New Issue
Block a user