Ecto generate migration file from a DB

I do have a DB with 117 tables and I would like to move our system to Elixir with Ecto. But I do not want to create all Ecto migration files by hand. I would like to know if there is a way to generate an Ecto migration file base on my DB?

Hey! I don’t think you need to create any migrations at all. You can just mix ecto.dump and get a structure.sql file. When you want to make further changes to the DB you use migrations of course, but to get things going the structure.sql file is super useful.

1 Like

How can I create models from structure.sql , do you have any tool ?

after created your structure.sql, you can run mix migrates it will use your structure.sql just created

This tool can help you achieve that.

1 Like