Different DB for dev and prod

Hello!

Is it possible to use with Ecto different databeses - MySQL for dev environment and Postgres for prod?

Thanks!
Denis

Yes I believe so. If you check the dev.exs and prod.exs you have:

  adapter: Ecto.Adapters.MySQL,
  username: "root",
  password: "root",
  database: "app_dev",
  hostname: "localhost",
  pool_size: 10

If you change the adapter to be Postgres and pass the necessary username, password, etc, I don’t see why it wouldn’t work. BUT, Postgres and MySQL might have slight differences (I never used Postgres) and the Ecto adapters and ecto functions you use in your code may end up giving different results.

4 Likes

Yes, I understand that I should use same Ecto functions.
Thanks for your opinion!

In my opinion, not just Ecto functions, but queries, SQL functions and workflows that will reproduce the same behaviours in both MySQL and Postgres.

Yes, all that can differ in databases.

Why would you want to use different DBs? It is best to use the same DB for both production and development so you can be reasonably sure that what you are developing will work in production.

Using different db’s is just asking for trouble/headaches imo :lol:

1 Like

Just for interest.

I will use Postgres as prod and I wanted to use MySQL for dev, because MySQL has such nice MySQL Workbench tool :slight_smile:

Now I am sure that I will work only with Postgres, because there may be need to use query fragments, which can be different in Postgres and MySQL…

BTW, Ecto 2.0 is compatible only with Postgres today

3 Likes