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

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
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
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New

We're in Beta

About us Mission Statement