commanded / eventstore

Event store using PostgreSQL for persistence
MIT License
1.05k stars 146 forks source link

Can't reset store for testing #254

Closed suzdalnitski closed 10 months ago

suzdalnitski commented 2 years ago

The following no longer works, because reset! now expects two args:

EventStore.Storage.Initializer.reset!(conn)

How should we reset the storage instead? What config does it expect?

Thanks!

suzdalnitski commented 2 years ago

I assume this is the correct approach now?

    config = Conduit.EventStore.config()

    {:ok, conn} = Postgrex.start_link(config)

    EventStore.Storage.Initializer.reset!(conn, config)
dvic commented 2 years ago

What is the error you're getting?

slashdotdash commented 10 months ago

For reference you can write a function to reset an event store as follows:

alias EventStore.Storage.Initializer

def reset_storage! do
  config = MyEventStore.config()

  with {:ok, conn} <- Postgrex.start_link(config) do
    try do
      Initializer.reset!(conn, config)
    after
      :ok = GenServer.stop(conn)
    end

    :ok
  end
end