<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Markus Chmelar</title>
    <description>The latest articles on DEV Community by Markus Chmelar (@ivmexx).</description>
    <link>https://dev.to/ivmexx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F80128%2F6edce4be-20a1-4a17-a7ec-8c1342747671.jpeg</url>
      <title>DEV Community: Markus Chmelar</title>
      <link>https://dev.to/ivmexx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ivmexx"/>
    <language>en</language>
    <item>
      <title>OSC Controlled LED Bodypack</title>
      <dc:creator>Markus Chmelar</dc:creator>
      <pubDate>Sun, 27 Dec 2020 19:19:26 +0000</pubDate>
      <link>https://dev.to/ivmexx/osc-controlled-led-bodypack-32cd</link>
      <guid>https://dev.to/ivmexx/osc-controlled-led-bodypack-32cd</guid>
      <description>&lt;p&gt;Don't you love a great light show at a concert? I know I do, and oh, how I miss going to and playing concerts already!&lt;/p&gt;

&lt;p&gt;I play in a band myself and we're always striving to deliver the best show we can with the limited possibilities a small, obscure local band has available. &lt;/p&gt;

&lt;p&gt;We have a small stage light setup that we bring to our shows to complement the venue's setup. Our fixtures are controlled from a set in Ableton Live, programmed to a click track, so the light show is synchronized to the music.&lt;/p&gt;

&lt;p&gt;Obviously, we're on a forced break right now, so I wanted to take the time to up our setup a notch! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: If you're not in a band or don't care about synchronization, you can skip most of the work and buy a complete &lt;a href="https://www.adafruit.com/product/2221"&gt;LED Goggle Kit&lt;/a&gt;. I found this only now while writing the post, but where's the fun in that anyway?&lt;/p&gt;

&lt;h1&gt;
  
  
  The Bodypack
&lt;/h1&gt;

&lt;p&gt;The overall plan is to add RGB LEDs to my costume and synchronize them to the rest of the light show and the music. &lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;The requirements are as follows&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Programmable from Ableton Live:&lt;/strong&gt; Everything is controlled via Ableton Live. I don't just want some random blinking lights on me, everything has to work together!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wireless Communication:&lt;/strong&gt; The rest of our light fixtures are placed somewhere on the stage and controlled via DMX over cable. But we ourselves are running around the stage. Therefore, the communication has to work without a cable!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wireless Power:&lt;/strong&gt; Again - no cables!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sneak Peek
&lt;/h2&gt;

&lt;p&gt;Here's a sneak peek of what I came up with: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X55X-zbh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g03fx8c6tdhr85raojxf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X55X-zbh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g03fx8c6tdhr85raojxf.gif" alt="Sneak Peek"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two &lt;a href="https://www.adafruit.com/category/168"&gt;Adafruit Neopixel&lt;/a&gt; rings with individually controllable RGB LEDs&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.raspberrypi.org/products/raspberry-pi-zero/"&gt;Raspberry Pi Zero&lt;/a&gt; with custom Elixir code to receive OSC messages sent by Ableton Live over Wifi&lt;/li&gt;
&lt;li&gt;A USB Power bank &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alright, lets dig into the details of how this all works, and how you too can add some more LEDs to your band's stage show! &lt;/p&gt;

&lt;h1&gt;
  
  
  Let's get building
&lt;/h1&gt;

&lt;p&gt;Alright, first things first - the hardware! &lt;/p&gt;

&lt;h3&gt;
  
  
  LEDs
&lt;/h3&gt;

&lt;p&gt;The most important components are the LEDs. I want RGB LEDs and they need to be individually programmable. In fact, this whole idea started when I learned about WS2812 type LEDs by accident. &lt;/p&gt;

&lt;p&gt;They usually come in long strips that you can cut at any point to your required length, but Adafruit took it a step further and offers a lot of different shapes and sizes under their &lt;a href="https://www.adafruit.com/category/168"&gt;NEOPIXELS&lt;/a&gt; brand.&lt;/p&gt;

&lt;p&gt;For this specific project, I decided to get two 16 LED rings because they fit perfectly on my goggles (as I've learned now, thats not by accident - Adafruit also offers a complete set with the exact same goggles and LED rings to go together).&lt;/p&gt;

&lt;h3&gt;
  
  
  Control
&lt;/h3&gt;

&lt;p&gt;Next, we need a means to control these LEDs. Neopixels are originally intended to be used with Adafruit's own Microcontroller boards, an Arduino or something similar. &lt;br&gt;
However, I already had some unused Raspberry PIs laying around that I wanted to make use of. &lt;/p&gt;

&lt;p&gt;This &lt;a href="https://tutorials-raspberrypi.com/connect-control-raspberry-pi-ws2812-rgb-led-strips/"&gt;tutorial on how to control WS2812 LEDs with a Raspberry Pi&lt;/a&gt; was exactly what I needed to get started.&lt;/p&gt;
&lt;h3&gt;
  
  
  Power
&lt;/h3&gt;

&lt;p&gt;The last pice is a way to power everything. Most tutorials just use a (socket) power supply, but I want to be mobile!&lt;/p&gt;

&lt;p&gt;The Raspberry Pi is powered via USB, the NeoPixels require 5V, the same voltage that USB delivers, so that matches up. I'm going to use a USB Power bank.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But wait&lt;/strong&gt;, here's a problem: These LEDs actually need a lot of power, especially when you'r buying a dense strip and the number of LEDs adds up.&lt;/p&gt;

&lt;p&gt;Each single LED draws up to 60mA when fully powered (20mA per color). &lt;br&gt;
I did not find reliable information about how much current the Pi can drive, answers are ranging from 200mA to (1A - however the Pi needs itself).&lt;br&gt;
In any case, thats (far) less than 16 LEDs, and I want to drive 2 Rings with 16 LEDs each.&lt;br&gt;
The second important factor of course is how long you can power the LEDs with the battery...&lt;/p&gt;

&lt;p&gt;After some search I found a &lt;a href="https://www.cyberport.at/smartphone-und-foto/zubehoer-smartphones/akkus/anker/pdp/3k01-00p/anker-powercore-15600-mah-powerbank-schwarz.html"&gt;massive Power bank&lt;/a&gt; with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2 USB ports - 1 for the Pi and 1 for the LEDs&lt;/li&gt;
&lt;li&gt;3A max - enough for 50 LEDs &lt;/li&gt;
&lt;li&gt;15600mAh - enough to deliver those 3A for more than 5 hours&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One detail to keep in mind: Most power banks turn off if they are "not used", i.e. if "no" current is drawn. The Raspberry Zero seems to draw so little current, that this is actually a problem.&lt;/p&gt;

&lt;p&gt;However, the LEDs always draw some current, even when dark. I don't have exact numbers, but found that the bias current of 32 LEDs plus the Raspberry is enough to keep the power bank from turning off.&lt;/p&gt;
&lt;h3&gt;
  
  
  Putting it all together
&lt;/h3&gt;

&lt;p&gt;Connecting everything is easy, but not trivial. The things you'll need to watch out for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Pi and the LEDs are powered by different USB Ports, but they need a common &lt;code&gt;ground&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The Data is sent on &lt;code&gt;GPIO 18&lt;/code&gt; of the Pi's GPIO pins.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;470Ω&lt;/code&gt; resistor should be placed on the data line as close to the first LED as possible&lt;/li&gt;
&lt;li&gt;LEDs can be chained together, from &lt;code&gt;Out&lt;/code&gt; of one to &lt;code&gt;In&lt;/code&gt; of the next&lt;/li&gt;
&lt;li&gt;It's always a good idea to add a decoupling capacitor between &lt;code&gt;+5V&lt;/code&gt; and &lt;code&gt;ground&lt;/code&gt; close to the first LED to help with sudden power draw when switching the LEDs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With that being said - here's the finished circuit:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MfHe4NRM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f2hj0wlvr9sdp3hohfqm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MfHe4NRM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f2hj0wlvr9sdp3hohfqm.png" alt="Schematic"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Let's get hackin'
&lt;/h1&gt;

&lt;p&gt;Alright, next step - controlling the LEDs!&lt;/p&gt;
&lt;h3&gt;
  
  
  RPI-WS2812-Server
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/tom-2015/rpi-ws2812-server"&gt;RPI-WS2812-Server&lt;/a&gt; is a great program to actually drive the LEDs via PWM. &lt;br&gt;
Follow the instructions to setup, and you're ready to play around. &lt;/p&gt;

&lt;p&gt;For example, to achieve the effect in the sneak peek, use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ./ws2812svr

setup 1,32,3;
init;
brightness 1,15;
rainbow 1,2;
do; rotate 1; render; delay 25; loop 150;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line sets up the program. We have 1 channel with 32 LEDs, and the NeoPixels (at least the ones I have) need the &lt;code&gt;WS2811_STRIP_GBR&lt;/code&gt; configuration. Then it's necessary to call &lt;code&gt;init&lt;/code&gt;.&lt;br&gt;
Next, turn down the brightness a bit - at full brightness these LEDs are &lt;strong&gt;really&lt;/strong&gt; bright! &lt;br&gt;
&lt;code&gt;rainbow&lt;/code&gt; sets up the nice color gradient, &lt;code&gt;1&lt;/code&gt; is the channel and &lt;code&gt;2&lt;/code&gt; means we want 2 repetitions - so each ring has a full gradient. &lt;br&gt;
The last line defines a loop that rotates the colors by 1, renders the new pattern and waits for 25ms before repeating the same process. After 150 iterations (or 3,75sek) the loop finishes.&lt;/p&gt;

&lt;p&gt;Eventually, we want this program to run automatically when we power up the Bodypack, so make sure to follow the &lt;a href="https://github.com/tom-2015/rpi-ws2812-server#running-as-a-service"&gt;Steps to run Ws2812-Server as a Service&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The program can even start up its own TCP server, so - out of the box - you can control the LEDs over the network.&lt;/p&gt;

&lt;p&gt;Assuming you have left the default port of &lt;code&gt;9999&lt;/code&gt; and know the IP address, you can use &lt;a href="https://wiki.ubuntuusers.de/netcat/"&gt;netcat&lt;/a&gt; to do so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netcat 192.168.1.149 9999

fill 1,32,00ff00;
render;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That might already be all you need, but I want to control the LEDs via &lt;a href="https://de.wikipedia.org/wiki/Open_Sound_Control"&gt;OSC&lt;/a&gt; so I can control them from Ableton Live.&lt;/p&gt;

&lt;h3&gt;
  
  
  Receiving OSC
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;O&lt;/strong&gt;pen &lt;strong&gt;S&lt;/strong&gt;ound &lt;strong&gt;C&lt;/strong&gt;ontrol is a protocol for networking between computers, synthesizers and other multimedia devices. Its more flexible than MIDI with a free naming scheme for parameters and much higher resolution. Also, OSC messages can be sent via Network.&lt;/p&gt;

&lt;p&gt;I've decided to build an Elixir service that runs on the Pi. It receives OSC messages via UDP and translates them to WS2812 commands which are finally passed on to RPI-WS2812-Server. &lt;/p&gt;

&lt;p&gt;The basic structure is based on &lt;a href="https://elixir-lang.org/blog/2016/07/14/announcing-genstage/"&gt;GenStage&lt;/a&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A UDP server that receives UDP packages and parses them into OSC messages - this is a GenStage &lt;code&gt;producer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;producer_consumer&lt;/code&gt; that translates OSC messages to WS2812 commands. This is the place to let your imagination run wild! In my first proof of concept, I have just implemented "global" brightness, red, green and blue commands. They allow me to control the color and brightness of both rings as one unit, but only that. In the future I want to add a lot more detail.&lt;/li&gt;
&lt;li&gt;A TCP server is the &lt;code&gt;consumer&lt;/code&gt; that connects to the WS2812 TCP server to send the translated commands over.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you're interested, you can find the &lt;a href="https://github.com/iv-mexx/bodypack"&gt;code on github&lt;/a&gt;, but beware: this is just a first proof of concept version with all the configuration hardcoded and no customization support yet.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's get creative
&lt;/h1&gt;

&lt;p&gt;This is where we can get creative and program our light show!&lt;/p&gt;

&lt;p&gt;For our "normal" fixtures, we use &lt;a href="https://www.dmxis.com"&gt;DMXIS&lt;/a&gt; to control the lights via &lt;a href="https://en.wikipedia.org/wiki/DMX512"&gt;DMX512&lt;/a&gt;. Its a USB to DMX interface that comes with a VST plugin that you can use in any DAW to program your DMX devices via Midi and automations. &lt;/p&gt;

&lt;p&gt;My DAW of choice is Ableton Live. The &lt;a href="https://www.ableton.com/de/packs/connection-kit/"&gt;Connection-Kit&lt;/a&gt; pack contains a device that can send OSC messages. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PPfdMj0F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hxehrfpa8hsyim5w1mfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PPfdMj0F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hxehrfpa8hsyim5w1mfg.png" alt="Screenshot 2020-12-27 at 19.13.49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this device set up, its possible to draw automations for the various parameters - exactly the same as with the DMXIS plugin.&lt;/p&gt;

&lt;p&gt;Finally, here's an example of a programmed part:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZY4Ql8Y4zKg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;In this article I've described the implementation of a mobile, programmable LED system that can be used in costumes on stage and be synchronized to a programmed light show. &lt;/p&gt;

&lt;p&gt;As of today, this project is in a working proof of concept state and if you're interested in building something similar yourself, you can take this as a starting point - the code is &lt;a href="https://github.com/iv-mexx/bodypack"&gt;shared on github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the next steps, I want to implement some animations that actually make use of the possibility to control each individual LED, but I have not yet decided how exactly this should work. &lt;/p&gt;

&lt;p&gt;Later, I want to make the elixir service more configurable and work on some additional LED configurations for the other band members.&lt;/p&gt;

</description>
      <category>osc</category>
      <category>elixir</category>
      <category>raspberrypi</category>
      <category>ws2812</category>
    </item>
    <item>
      <title>Migrate from Rails to Phoenix </title>
      <dc:creator>Markus Chmelar</dc:creator>
      <pubDate>Sat, 11 Jul 2020 22:02:52 +0000</pubDate>
      <link>https://dev.to/ivmexx/migrate-from-rails-to-phoenix-2mmn</link>
      <guid>https://dev.to/ivmexx/migrate-from-rails-to-phoenix-2mmn</guid>
      <description>&lt;p&gt;Say you have a running Rails app and want to migrate the app to Phoenix for whatever reason. &lt;/p&gt;

&lt;p&gt;I'll be honest - in my case, it's just because I'm curious about Phoenix and want to learn more about it. &lt;/p&gt;

&lt;p&gt;The Rails app in question is a relatively simple JSON API backend for iOS- and Android mobile apps, as well as a Javascript Web Client. &lt;/p&gt;

&lt;p&gt;I want to be able to run both servers in parallel to compare both versions and to eventually switch over without interruption. For these reasons, I want to keep using the existing Postgres database.&lt;/p&gt;

&lt;p&gt;In this post, I'm describing the steps that are necessary to get started. I'll assume you are already familiar with Phoenix and will only cover the special steps necessary to use the existing Postgres database from a Rails app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dump Schema
&lt;/h2&gt;

&lt;p&gt;In order to load your existing database schema from Rails in your Phoenix app, you'll need to dump the database schema as &lt;code&gt;structure.sql&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;rails db:structure:dump&lt;/code&gt; in your Rails App&lt;/li&gt;
&lt;li&gt;Copy the generated &lt;code&gt;structure.sql&lt;/code&gt; file to &lt;code&gt;priv/repo/structure.sql&lt;/code&gt; in your Phoenix App&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can now load the structure in your Phoenix App via &lt;code&gt;mix ecto.load&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, you can directly use the existing database. For tests, it's still necessary to have the &lt;code&gt;structure.sql&lt;/code&gt; ready to create the test database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Schemas, delete Ecto Migrations
&lt;/h2&gt;

&lt;p&gt;Create your schemas such that they exactly match your existing database structure.&lt;/p&gt;

&lt;p&gt;This is not too hard since Ecto is a bit more configurable than ActiveRecord and naming conventions seem to match up pretty well anyway.&lt;/p&gt;

&lt;p&gt;If you've used generators to generate your schemas, mix will also have created migrations for you. &lt;/p&gt;

&lt;p&gt;Since the database structure is already loaded, you'll need to delete these migration files. Otherwise, Phoenix will not run because of pending migrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix Timestamps
&lt;/h2&gt;

&lt;p&gt;By default, Ecto uses &lt;code&gt;inserted_at&lt;/code&gt; and &lt;code&gt;updated_at&lt;/code&gt; for timestamps while Active Record uses &lt;code&gt;created_at&lt;/code&gt; and &lt;code&gt;updated_at&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The latter is not a problem, but the former is different, so you will get errors like this one&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;** (Postgrex.Error) ERROR 42703 (undefined_column) column "inserted_at" of relation "maps" does not exist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its easy to tell Ecto to use custom names for timestamp columns, by using the following option in your schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  schema "maps" do
    # Your fields...

    timestamps(inserted_at: :created_at)
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adjust Ecto Tasks
&lt;/h2&gt;

&lt;p&gt;By default, the provided mix tasks will run the migrations to create the database.&lt;/p&gt;

&lt;p&gt;For normal development, you might not mind because you ran &lt;code&gt;mix ecto.load&lt;/code&gt; manually or are using your existing rails database.&lt;/p&gt;

&lt;p&gt;But when testing, &lt;code&gt;mix&lt;/code&gt; will by default clear and re-create the test database on each run via migrations, which will not work.&lt;/p&gt;

&lt;p&gt;To fix this, you can adjust the aliases in your &lt;code&gt;mix.exs&lt;/code&gt; file to load the existing structure instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  defp aliases do
    [
      setup: ["deps.get", "ecto.setup", "cmd npm install --prefix assets"],
      "ecto.setup": ["ecto.create", "ecto.load", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: [
        "ecto.drop",
        "ecto.create --quiet",
        "ecto.load --quiet --skip-if-loaded",
        "ecto.migrate --quiet",
        "test"
      ]
    ]
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pay attention to the &lt;code&gt;--skip-if-loaded&lt;/code&gt; option in the &lt;code&gt;test&lt;/code&gt; alias, otherwise you'll need to confirm that the schema is already loaded on each test run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use the existing database from your Rails App
&lt;/h2&gt;

&lt;p&gt;To use the existing database directly instead of creating a new database that just has the same structure, all you need to do is setup your Repo in &lt;code&gt;dev.exs&lt;/code&gt; or &lt;code&gt;prod.exs&lt;/code&gt; with the same configuration from your Rails' &lt;code&gt;database.yml&lt;/code&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Phoenix Migrations
&lt;/h2&gt;

&lt;p&gt;To use Phoenix for further migrations, you'll need to change one more config. Both, Rails and Phoenix use the same table, &lt;code&gt;schema_migrations&lt;/code&gt;, to manage migrations, but they have slightly different format.&lt;/p&gt;

&lt;p&gt;To circumvent this issue, you'll have to configure Ecto to use a different table to manage migrations by setting a custom name for &lt;code&gt;migration_source&lt;/code&gt;, e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Configure your database
config :myApp, MyApp.Repo,
  username: "postgres",
  password: "postgres",
  database: "myapp-development",
  hostname: "localhost",
  show_sensitive_data_on_connection_error: true,
  pool_size: 10,
  # The App was started from Rails which used the `schema_migrations` table with the same name but different schema
  # To continue with migrations from ecto from now on, we use choose a custom name for the ecto migrations
  # !!! From now on, migrations should only be done from Ecto !!!
  migration_source: "ecto_schema_migrations"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One word of caution though: From that point onward, you should ONLY use Phoenix for your new migrations! Since Phoenix does not know about Rails migrations and vice versa, if you mix them it would be too easy to fuck up and break your database schema!&lt;/p&gt;

&lt;h2&gt;
  
  
  Thats it
&lt;/h2&gt;

&lt;p&gt;Now have fun re-writing your Rails App in Phoenix 😇&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>elixir</category>
      <category>phoenix</category>
    </item>
  </channel>
</rss>
