Aadmaa

Aadmaa

Ecto equivalent for "prisma db pull"?

Once nice thing about Prisma is you can connect to an existing database, and use the CLI to run “prisma db pull” - and then it uses introspection on the database to build a nice model file.

The thing that is not as nice, is then the models are prisma models, not Ecto schemas :slight_smile:

Is there an up-to-date / still working Elixir project to do the same thing?

Most Liked

frankdugan3

frankdugan3

This would indeed be very nice for brownfield projects, or spinning up an API for an existing app. If you are interested in creating a generator, the Endo project would give you a good boost by providing DB introspection.

D4no0

D4no0

Ecto schemas are not guaranteed to be 1:1 with database table structure (this is done by design to avoid coupling), hence why when we run migrations, we use the explicit approach for creating a table:

defmodule MyRepo.Migrations.AddWeatherTable do
  use Ecto.Migration

  def change do
    create table("weather") do
      add :city,    :string, size: 40
      add :temp_lo, :integer
      add :temp_hi, :integer
      add :prcp,    :float

      timestamps()
    end
  end
end

As you can see there are zero references to the underlying schema that will be using this table.

Taking this in consideration, I’m not entirely sure what value such a tool would have, even if you had to integrate with a new database, the time spent on initial creation of schemas would not be that long.

D4no0

D4no0

While I understand the benefits, building such a tool might not be that trivial, especially if you expect the relations to be determined too.

I think it could be an interesting project for someone trying to learn how to play with generators, but the value it would bring would not be that great sadly, as creation of schemas in mass is not something you do often.

This implies that you need all those schemas out of the gate, otherwise you can create and improve the schemas iteratively, this is what I usually do and it works like a charm.

Last Post!

dimitarvp

dimitarvp

There’s also this but no idea if it works still.

https://github.com/saleyn/plsm

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement