dwyl / alog

🌲 alog (Append-only Log) is an easy way to start using the Lambda/Kappa architecture in your Elixir/Phoenix Apps while still using PostgreSQL (with Ecto).
GNU General Public License v2.0
15 stars 2 forks source link

Check timestamps are defined? #19

Open SimonLab opened 5 years ago

SimonLab commented 5 years ago

alog is checking that the schemas of the application have the minimum fields defined to allow the package to work: https://github.com/dwyl/alog/blob/4cbf9d7f3399a665a9b59c5ed0cb96a0e27afc59/lib/alog.ex#L68 https://github.com/dwyl/alog/blob/4cbf9d7f3399a665a9b59c5ed0cb96a0e27afc59/lib/alog.ex#L79

However it doesn't check that timestamps are defined. timestamps are used in the queries to make sure to retrieve the correct item: https://github.com/dwyl/alog/blob/4cbf9d7f3399a665a9b59c5ed0cb96a0e27afc59/lib/alog.ex#L106-L114 Do we need to add a check for inserted_at and updated_at and if yes do we want to check that the type of these value is naive_datetime_usec to make sure that microseconds are saved in Postgres?

see https://hexdocs.pm/ecto/Ecto.Schema.html#module-the-datetime-types

Danwhy commented 5 years ago

:+1: Timestamps are necessary so we probably should require them the same way.

I don't think it's necessary that the type be naive_datetime_usec though. The timestamps are used to ensure we're fetching the most recent update of an item, and I don't think it's likely that two relevant updates would be performed within microseconds of each other. Saying that though, it would provide more of a guarantee of correct data, so maybe we should recommend it rather than require it.