There're situations when I need to insert 2 objects of the same Struct into a database, via Ecto, such that inserted_at or updated_at of one of the Struct should differ only by 1 second from the other one.
I insert 2 struct objects sequentally, one after right the other, and their inserted_at and updated_at turn out to be identical. Whereas I want a 2nd object to have inserted_at and updated_at greater by 1 second to a 1st one, so that later on when I retrieve them from a database and show on a page, data will make more sense.
Supplying inserted_at or updated_at + 1 second to a changeset structure of a 2nd object didn't help because they got ignored by Ecto, and both objects got identical inserted_at and updated_at values.
Calling :os.sleep(1000) between the calls to insert will be a bad option.
How can I do it?