Deploy Missing Piece
  • Need for distillery to run migrations on deploy

    • We need to create release tasks that will go in the root of lib.
      • That will have a migration and / or seed function in it.
    • Then in the rel/config.exs we a list of tuples that have the task command, what we want to refer to it as, and the the shell script that we want it to run.
    • Remember mix isn't installed on the prod machine!
    • the shell script just calls bin/postit command Elixir.Postit.ReleaseTasks migrate
    • Then we, to run migration on app launch for new builds, back in rel/config.ex we add set post_start_hooks: "rel/hooks/post_start" to env prod. in this directory we have a single shell script that will use nodetool to ping when the, not app, but BEAM? is up and running, and then run the migration.
    #!/usr/bin/env bash set +e while true; do nodetool ping EXIT_CODE=$? if [[ ${EXIT_CODE} -eq 0 ]]; then echo "Application is up!" break fi done set -e echo "Running migrations" bin/postit command Elixir.Release.Tasks migrate echo "Migrations run successfully"
  • It's great that I had the command correct in the this write up.

    • bc i didn't in the post_start script or the set commands script
    • currently it's in both to see which if both run?

    Custom commands give you a lot of power to express potentially complex operations as a terse statement. I would encourage you to use them for these types of tasks rather than using the raw rpc and eval tasks!

  • App Engine to remove old instances

    • save that for another day, i'm all dev ops out.
  • Force SSL

    • we figured out that we'd forgotten the force_ssl : [] part all together. 🤦‍♂️
  • We are pretty bad at CSS. In a perpetual cycle kind of way. So we need to be better. This is definitely an area where we need to improve on.

Missing Model Features
  • Posts will need to be a many-to-one to users or 'authors'
  • mix ecto.gen.migration update_posts_with_user_relationship
    • why? so we can list posts by author. 🤦‍♂️
    • post's are not editable. once published, it's done
    • auto saving versions for undo?
      • would that be a Postgres implementation? Where would that line be?

build_assoc(struct, assoc, attributes \ %{})
Builds a struct from the given assoc in model.

If the relationship is a has_one or has_many and the key is set in the given model, the key will automatically be set in the built association
/ Ecto Documentation

def change do alter table("posts") do add: user_id, :uuid end
  • We're adding a column to our posts table user_id with data type uuid, as it should be a unique identifier? But I don't really know, bc it's coming from auth0. Still happy I didn't role my own.
  • Option B is we could reallocate the user table from auth0 i believe to be in our own database and then create a user scheme to get the info we need from it. That might be an option for another day?
  • Search: elixir pattern match 2 string keys
def create(conn, %{"post" => post_params}) do case Posting.create_post(post_params) do {:ok, post} ->
  • if I understand it I need to leverage pattern matching to get the user_id out of conn and into a map to pass to create_post which takes a single argument.
  • protocol String.Chars not implemented for oh noes
  • We want a profile page for users

    • can add 3rd party API Tokens
    • update display name
    • how does that work with auth0 as a user table
    • should we move the storage table of users from auth0 to gcloud?
Resources Follow

Podden och tillhörande omslagsbild på den här sidan tillhör Jesse Tomchak. Innehållet i podden är skapat av Jesse Tomchak och inte av, eller tillsammans med, Poddtoppen.