mix local.hex
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
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
https://elixircasts.io/deploying-elixir-with-heroku https://hexdocs.pm/phoenix/heroku.html