Skip to content

Commit

Permalink
update database setting for local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbryant committed Dec 7, 2024
1 parent 63fb50c commit bc32c52
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
image: postgres
restart: always
environment:
POSTGRES_DB: todo_store
POSTGRES_PASSWORD: Monkey1234
volumes:
- pgdata:/var/lib/postgresql/data
Expand Down
7 changes: 4 additions & 3 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Server
open System.Text.Json.Serialization
open Fable.Remoting.Server
open Fable.Remoting.Giraffe
open JasperFx.CodeGeneration
open Marten.Events.Projections
open Marten.Services
open Microsoft.AspNetCore.Http
Expand Down Expand Up @@ -63,14 +62,14 @@ let webApp =
|> Remoting.fromContext todosApi
|> Remoting.buildHttpHandler

let configureServices (services: IServiceCollection) =
let marten (services: IServiceCollection) =
services.AddMarten(fun (options: StoreOptions) ->
let config =
services.BuildServiceProvider().GetService<IConfiguration>()

options.Connection(config.GetConnectionString "Db")

options.AutoCreateSchemaObjects <- AutoCreate.All
options.AutoCreateSchemaObjects <- AutoCreate.CreateOrUpdate

options.Projections.Snapshot<Todo> SnapshotLifecycle.Inline |> ignore
options.Projections.LiveStreamAggregation<TodoHistory> |> ignore
Expand All @@ -82,6 +81,8 @@ let configureServices (services: IServiceCollection) =

services

let configureServices = marten

let app = application {
use_router webApp
service_config configureServices
Expand Down
2 changes: 1 addition & 1 deletion src/Server/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"Db": "host=localhost;port=5432;database=postgres;password=Monkey1234;username=postgres;"
"Db": "host=localhost;port=5432;database=todo_store;password=Monkey1234;username=postgres;"
}
}

0 comments on commit bc32c52

Please sign in to comment.