Best practice integrating Phoenix with existing database

I recently migrated a Python/MySQL app to Phoenix and the only thing I really needed to do was use create_if_not_exists.

create_if_not_exists table(:thing)

Then the migrations work fine for tests but don’t do anything in production.

Because I was had to use MySQL I also had to wrap index creation in an environment check, but if you’re using Postgres I think create if not exists should work fine with indexes.

I had about 30 tables to create, it wasn’t exactly a fun task but it only needed doing once and going through all the detail by hand was quite beneficial to understanding everything.

5 Likes