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

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
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
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
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
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement