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

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics 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
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
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
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New