Skip to content

Allow setting any schema #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/Postgres.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ type PostgresConfig =
port: string
username: string
password: string
database: string }
database: string
schema: string option }

type PoolingConfig =
{ minPoolSize: int option
Expand Down Expand Up @@ -50,12 +51,28 @@ module Postgres =
let private storeSettingsWithPooling (config: PostgresConfig) (pooling: PoolingConfig): string =
sprintf "%s;%s" (storeSettings config) (poolingSettings pooling)

let private setSettingsSchema (config: PostgresConfig)
(settings: SqlStreamStore.PostgresStreamStoreSettings)
: SqlStreamStore.PostgresStreamStoreSettings =
match config.schema with
| None -> ()
| Some (schema) -> settings.Schema <- schema

settings

let createStore (config: PostgresConfig): SqlStreamStore.PostgresStreamStore =
new SqlStreamStore.PostgresStreamStore(SqlStreamStore.PostgresStreamStoreSettings(storeSettings config))
let settings =
SqlStreamStore.PostgresStreamStoreSettings(storeSettings config)
|> setSettingsSchema config

new SqlStreamStore.PostgresStreamStore(settings)

let createStoreWithPoolingConfig (config: PostgresConfig) (pooling: PoolingConfig): SqlStreamStore.PostgresStreamStore =
new SqlStreamStore.PostgresStreamStore(SqlStreamStore.PostgresStreamStoreSettings
(storeSettingsWithPooling config pooling))
let settings =
SqlStreamStore.PostgresStreamStoreSettings(storeSettingsWithPooling config pooling)
|> setSettingsSchema config

new SqlStreamStore.PostgresStreamStore(settings)

let createStoreWithConfigString (config: string): SqlStreamStore.PostgresStreamStore =
new SqlStreamStore.PostgresStreamStore(SqlStreamStore.PostgresStreamStoreSettings(config))
Expand Down