You might be interested in learning more about ecto sandbox:
https://medium.com/@qertoip/making-sense-of-ecto-2-sql-sandbox-and-connection-ownership-modes-b45c5337c6b7
https://hexdocs.pm/ecto/Ecto.Adapters.SQL.Sandbox.html