Skip to content

Instantly share code, notes, and snippets.

@claritee
Last active April 22, 2018 06:08
Show Gist options
  • Save claritee/461daf45e104c4e085214fe6de8f67ff to your computer and use it in GitHub Desktop.
Save claritee/461daf45e104c4e085214fe6de8f67ff to your computer and use it in GitHub Desktop.
Phoenix Notes

Notes on Phoenix

Install

mix local.hex
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Hello World

New project:

mix phx.new hello

DB config:

cd hello
config/dev.exs

Create DB:

mix ecto.create

To reset DB:

mix ecto.reset

Start the app:

mix phx.server

or run inside iex

iex -S mix phx.server

Go to

http://localhost:4000

DB requirements

- postgres installed
- postgres db and user

DB Troubleshooting

(1) Issue: psql: FATAL: role “postgres” does not exist

Create user and role

psql
> CREATE USER postgres SUPERUSER;
> CREATE DATABASE postgres WITH OWNER postgres;

Or if only need to grant privileges

GRANT ALL PRIVILEGES ON DATABASE "my_db" to my_user;

(2) If psql is referencing older version of readline

psql
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/psql
ls -l /usr/local/opt/readline/lib/
brew reinstall readline
brew upgrade postgresql

(3) FATAL: database does not exist

createdb <user>

(4) DB version is old

brew postgresql-upgrade-database

Heroku

https://elixircasts.io/deploying-elixir-with-heroku https://hexdocs.pm/phoenix/heroku.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment