Radio and PodcastRadio and PodcastLive Radio & Podcasts
Elixir Ecto Models artwork
Technology

Elixir Ecto Models

Javascript to Elm by Jesse Tomchak

Aug 3, 201927:25Technology

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...

About This Episode

Elixir Ecto Models is an episode from Javascript to Elm by Jesse Tomchak. 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 /...

Podcast

This episode belongs to Javascript to Elm.

Listen Online

Use the player on this page to stream the episode online.

Episode Details

Published Aug 3, 2019, 27:25 long, audio available.

Questions About This Episode

What is Elixir Ecto Models about?

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 mkdocs The Docs on Hex run ecto migrations in prod running ecto migrations with distillery running migrations Elixir Form talks Using Bulma and Sass in Phoenix external id's for ecto notes on elixir pattern matching current user in elixir phoenix Follow JavaScript to Elm Twitter: @jstoelm Email: jesse@jstoelm.com Jesse Tomchak Twitter: @jtomchak

Where can I listen to Elixir Ecto Models?

You can listen to Elixir Ecto Models online on Radio and Podcast. Open the player on this page to stream the available audio.

Which podcast is Elixir Ecto Models from?

Elixir Ecto Models is an episode from Javascript to Elm by Jesse Tomchak.

How long is this episode?

This episode is 27:25 long.

When was this episode published?

This episode was published on Aug 3, 2019.

Can I save Elixir Ecto Models for later?

Yes. Use the heart button on the episode page to add it to your favorite episodes list.

Are there related episodes from Javascript to Elm?

Yes. This page shows related episodes from Javascript to Elm when more episodes are available from the podcast feed.

Quick Answers About This Episode

Where can I listen to Elixir Ecto Models?

You can listen to Elixir Ecto Models on this page when the episode audio is available from the podcast feed.

Which podcast is this episode from?

Elixir Ecto Models is from Javascript to Elm by Jesse Tomchak.

What are the episode details?

Published Aug 3, 2019 and 27:25 long