This repo has been created to demonstrate how one could use Mnesia, with Ecto, in place of the typical database of Postgres or MySQL. The repo will be used as part of a demo/presentation taking place in September 2018 for the JaxEx Meetup.
- Elixir 1.6+
- Phoenix 1.3+
- Postgres 9.3.x (initially, though we will swap that out)
- NPM
Install the following, if needed:
# Install Elixir
brew install elixir (if on OS X) or your preferred method
Note: See the following for alternative ways to install Elixir
Install Hex Package Manager:
mix local.hex
Install Phoenix:
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Update NPM
npm upgrade
cd /path/to/your/elixir/projects
git clone https://github.com/hogihung/metademo_mnesia.git
cd metademo_mnesia
mix deps.get
mix ecto.create
mix ecto.migrate
Run the server:
iex -S mix phx.server
Now you can visit localhost:4000
from your browser.
- Open the file Seed_Data_Via_Curl_Post.txt in your favorite text editor
- Copy the curl examples that are doing a POST
- Paste those values into a terminal that can hit the Web App you started previously
- Via the browser, visit http://localhost:4000/api/hosts (view list of all hosts in DB)
- Via the browser, visit http://localhost:4000/api/hosts/1 (view one host)
TIP: Reset the database:
mix ecto.drop
mix ecto.create
mix ecto.migrate
# Stop the Phoenix Server:
cntrl+c / cntrl+c
# Change to Mnesia related branch:
git checkout convert_db_to_mnesia
# Pull in new dependencies:
mix deps.get
# Create the database for Mnesia
mkdir -p priv/data/mnesia
mix ecto.create
# Re-Run the migrations
mix ecto.migrate
# Re-start the Phoenix App
iex -S mix phx.server
- Article: A Trip Down Mnesia Lane
- Erlang Mnesia Overview
- Ecto Adapter for Mnesia
- Ecto Mnesia Repo on Github
- Ecto Query
- Ecto Repo
- Ecto Associatons
- Official website: http://www.phoenixframework.org/
- Guides: http://phoenixframework.org/docs/overview
- Docs: https://hexdocs.pm/phoenix
- Mailing list: http://groups.google.com/group/phoenix-talk
- Source: https://github.com/phoenixframework/phoenix
Ready to run in production? Please check our deployment guides.