Implement Append Only Log as an Ecto Adapter
- Dominant language
- Elixir
- Stars
- 15
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
We should look into implementing this module as an [Ecto Adapter](https://hexdocs.pm/ecto/Ecto.Adapter.html).
This will allow us greater control over the internals of the Ecto Repo, including allowing us to autogenerate a [cid](https://github.com/dwyl/cid) as the primary key, hopefully allowing us to require or predefine required fields such as :deleted and timestamps, and ensuring there are no unique indexes.
We are currently doing some of this, but only by taking advantage of macros. By implementing an Ecto Adapter, we can use the module in the exact way we would use the normal Postgres Adapter, so the learning curve will be minimal for anyone who has used Ecto before.
We can take advantage of the already existing functionality from [`Ecto.Adapters.SQL`](https://hexdocs.pm/ecto/2.2.8/Ecto.Adapters.SQL.html), re-implementing what we need to change, and keeping what we don't.
We should start with a simple tutorial explaining how to create an Ecto Adapter, then build on that.
https://michal.muskala.eu/2015/07/07/creating-ecto-adapters.html
http://blog.plataformatec.com.br/2019/01/building-a-new-mysql-adapter-for-ecto-part-iv-ecto-integration/
The following are the callbacks we need to define. Some of them we will be able to [`defdelegate`](https://hexdocs.pm/elixir/Kernel.html#defdelegate/2) to the existing `Ecto.Adapters.Postgres` module. There may also be others which are already defined as part of `Ecto.Adapters.SQL` but that we need to modify (some of the `Ecto.Adapter.Queryable` callbacks for example). We'll add those to the list as it becomes apparent we need them.
## Ecto.Adapters.SQL.Connection
- [ ] all(query) #40
- [ ] child_spec(options) #41
- [x] ddl_logs(result) - **defdelegate**
- [ ] delete(prefix, table, filters, returning) #42
- [ ] delete_all(query) #43
- [ ] execute(connection, cached, params, options) - **defdelegate?**
- [ ] execute_ddl(command) #44
- [ ] insert(prefix, table, header, rows, on_conflict, returning) #45
- [x] prepare_execute(connection, name, statement, params, options) - **defdelegate**
- [x] query(connection, statement, params, options) - **defdelegate**
- [x] stream(connection, statement, params, options) - **defdelegate**
- [ ] to_constraints(exception) - **maybe defdelegate, need more research**
- [ ] update(prefix, table, fields, filters, returning) #46
- [ ] update_all(query) #47
## Ecto.Adapter.Storage
- [x] storage_down(options) - **defdelegate**
- [x] storage_up(options) - **defdelegate**
## Ecto.Adapter.Migration
- [x] supports_ddl_transaction?() - **defdelegate or just return true**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.