Skip to content

Commit 88ba039

Browse files
roetlichstoft
andauthored
Allow setting any schema (#6)
* Allow setting any schema Co-authored-by: Till Schröder <[email protected]> * Enable setting schema also for store with pooling Co-authored-by: Rasmus Larsson <[email protected]>
1 parent ba9d09c commit 88ba039

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Postgres.fs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ type PostgresConfig =
77
port: string
88
username: string
99
password: string
10-
database: string }
10+
database: string
11+
schema: string option }
1112

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

54+
let private setSettingsSchema (config: PostgresConfig)
55+
(settings: SqlStreamStore.PostgresStreamStoreSettings)
56+
: SqlStreamStore.PostgresStreamStoreSettings =
57+
match config.schema with
58+
| None -> ()
59+
| Some (schema) -> settings.Schema <- schema
60+
61+
settings
62+
5363
let createStore (config: PostgresConfig): SqlStreamStore.PostgresStreamStore =
54-
new SqlStreamStore.PostgresStreamStore(SqlStreamStore.PostgresStreamStoreSettings(storeSettings config))
64+
let settings =
65+
SqlStreamStore.PostgresStreamStoreSettings(storeSettings config)
66+
|> setSettingsSchema config
67+
68+
new SqlStreamStore.PostgresStreamStore(settings)
5569

5670
let createStoreWithPoolingConfig (config: PostgresConfig) (pooling: PoolingConfig): SqlStreamStore.PostgresStreamStore =
57-
new SqlStreamStore.PostgresStreamStore(SqlStreamStore.PostgresStreamStoreSettings
58-
(storeSettingsWithPooling config pooling))
71+
let settings =
72+
SqlStreamStore.PostgresStreamStoreSettings(storeSettingsWithPooling config pooling)
73+
|> setSettingsSchema config
74+
75+
new SqlStreamStore.PostgresStreamStore(settings)
5976

6077
let createStoreWithConfigString (config: string): SqlStreamStore.PostgresStreamStore =
6178
new SqlStreamStore.PostgresStreamStore(SqlStreamStore.PostgresStreamStoreSettings(config))

0 commit comments

Comments
 (0)