Akka.Persistence.PostgreSql
Akka.Persistence.PostgreSql copied to clipboard
Use JSON data types for payload column
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:
- 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.
- 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
IActorRefto be functional after receiving from database. This is basically an anti-pattern, but it should work nonetheless.
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