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