Akka.Persistence.PostgreSql icon indicating copy to clipboard operation
Akka.Persistence.PostgreSql copied to clipboard

Use JSON data types for payload column

Open Horusiath opened this issue 10 years ago • 1 comments

The idea is to use Postgres specific data types, either JSON or (prefered?) JSONB. Advantages are quite obvious, as with this change, the database will be aware of content of events, giving the possibility to query by their fields.

However there are few challenges here:

  1. What to do with existing blob data? - since schema will change eventually in the near future, changes will occur this way or another. But changing column data type is more serious action. We could potentially introduce some switch mechanism or try to use event adapters for that.
  2. How combine this approach with surrogates. Personally I don't have an experience with serializing/deserializing json data types between PostgreSQL and .NET, but one of the problems we could possibly need to resolve is conversion of things such as IActorRef to be functional after receiving from database. This is basically an anti-pattern, but it should work nonetheless.

Horusiath avatar Oct 24 '15 16:10 Horusiath

Isn't this already possible? Just pass in JSON here:

https://github.com/akkadotnet/Akka.Persistence.PostgreSql/blob/dev/src/Akka.Persistence.PostgreSql/Journal/PostgreSqlQueryExecutor.cs#L35

It will create the payload as json: https://github.com/akkadotnet/Akka.Persistence.PostgreSql/blob/dev/src/Akka.Persistence.PostgreSql/Journal/PostgreSqlQueryExecutor.cs#L45

CumpsD avatar Mar 21 '21 23:03 CumpsD