dwyl / phoenix-ecto-append-only-log-example

📝 A step-by-step example/tutorial showing how to build a Phoenix (Elixir) App where all data is immutable (append only). Precursor to Blockchain, IPFS or Solid!
GNU General Public License v2.0
78 stars 7 forks source link

Tutorial for Append Only Database/Log #2

Closed Danwhy closed 5 years ago

Danwhy commented 5 years ago

Adds basic guide for creating a schema and a behaviour to facilitate an append only database, with code and tests.

There are still some improvements/advancements that could be made to the guide (see open questions in #1), but this should be a good starting point

nelsonic commented 5 years ago

@Danwhy I'm going to take a look at this tonight. please remove "[WiP]" if you feel it's "mergeable". thanks! 👍

Following along ...

Create SQL user: image

Install deps image

Create Database: image

Migrate: image

So far, so fail: image

👍

nelsonic commented 5 years ago
test add item to database (Append.AddressTest)
     test/append/address_test.exs:5
     ** (UndefinedFunctionError) function Repo.insert/1 is undefined (module Repo is not available)

image 😞

nelsonic commented 5 years ago

Have to add:

  alias Append.Repo

To the top of lib/append/append_only_log.ex as per: https://github.com/dwyl/phoenix-ecto-append-only-log-example/pull/2/files#diff-ba1c4c1b3f67bc03f7691e3253abce7dR2

then tests will pass: image

adding to code/instructions in README.md 😉

codecov[bot] commented 5 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@165818e). Click here to learn what that means. The diff coverage is 56.75%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #2   +/-   ##
=========================================
  Coverage          ?   56.75%           
=========================================
  Files             ?       11           
  Lines             ?       37           
  Branches          ?        0           
=========================================
  Hits              ?       21           
  Misses            ?       16           
  Partials          ?        0
Impacted Files Coverage Δ
test/support/channel_case.ex 0% <0%> (ø)
lib/append_web.ex 0% <0%> (ø)
lib/append_web/views/error_helpers.ex 0% <0%> (ø)
lib/append/address.ex 100% <100%> (ø)
test/support/conn_case.ex 100% <100%> (ø)
lib/append_web/controllers/page_controller.ex 100% <100%> (ø)
lib/append_web/views/error_view.ex 100% <100%> (ø)
lib/append_web/endpoint.ex 50% <50%> (ø)
test/support/data_case.ex 57.14% <57.14%> (ø)
lib/append_web/router.ex 66.66% <66.66%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 165818e...72394c2. Read the comment docs.

nelsonic commented 5 years ago

@Cleop thanks. 👍

nelsonic commented 5 years ago

Note: we still need to add the answers to the "intro questions": https://github.com/dwyl/phoenix-ecto-append-only-log-example/issues/1#issuecomment-424738578

I'm going to add those to a separate PR shortly. Merging this for now. 👍