The package can be installed from hex as follows.
-
Add
commanded_eventstore_adapter
to your list of dependencies inmix.exs
:def deps do [{:commanded_eventstore_adapter, "~> 1.4"}] end
Then run
mix deps.get
-
Create an event store for your application:
defmodule MyApp.EventStore do use EventStore, otp_app: :my_app end
-
Define and configure your Commanded application to use the
Commanded.EventStore.Adapters.EventStore
adapter and your own event store module:defmodule MyApp.Application do use Commanded.Application, otp_app: :my_app, event_store: [ adapter: Commanded.EventStore.Adapters.EventStore, event_store: MyApp.EventStore ] end
-
Configure the event store in each environment's mix config file (e.g.
config/dev.exs
), specifying usage of Commanded's JSON serializer:import Config config :my_app, MyApp.EventStore, serializer: Commanded.Serialization.JsonSerializer, username: "postgres", password: "postgres", database: "eventstore_dev", hostname: "localhost", pool_size: 10
-
Add your event store to
config/config.exs
to make it easier to use the EventStore mix tasks:# config/config.exs import Config config :my_app, event_stores: [MyApp.EventStore] import_config "#{config_env()}.exs"
-
Create the EventStore database and tables using the
mix
task:mix do event_store.create, event_store.init