Abhinav1217

Abhinav1217

Pulling schema updates from Postgres Db

I have few node microservices connected to single postgres db. I also have an elixir service for realtime message passing between BE and FE.

I am now enhancing realtime service with some additional features, so I added ecto and ash_postgres to mix and connected with postgres. Since core app is nodejs, I want that to be source of truth for db schema changes, and elixir should pull updated schema into the model layer. We have multi schema db, and public schema would be readonly, and elx would be full access schema for elixir.

I tried this using introspex
`mix ecto.gen.schema --repo RealtimeService.Repo.Public --path lib/realtime_service/ --module-prefix RealtimeService.Db.Public.Models --schema public` and it was able to generate initial schema but it just wrote comments for fields with enums and jsonb objects. Also I could not pull updates again.

Can someone guide me properly, most of chatgpt answers were wrong, Claude helped a little but now its just imagining things. I might be a programmer for decade but I am an elixir newbie

  1. I need a way to update model layer in elixir app, from db, any changes in db schema even if only needed by elixir app, will be done from node app to maintain single source of truth for db.
  2. Need enums also, jsonb could simply be a map, and I think array were successfully pulled.
  3. I also need to be able to pull schema changes again, without overwriting everything back.

Thanks.

Most Liked

zachdaniel

zachdaniel

Creator of Ash

Requires using Ash, but ash_postgres can do at least some of this. I don’t recall if we extract enums or not but that could be added likely. I think your question was tagged ash-postgres on happenstance not because you actually were using Ash, but thats what tagged me to come look :smiley:

If you use the --fragments option, it will keep a separate file per resource updated which is “managed” so as things change you can rerun and it will replace that fragment.

Last Post!

Abhinav1217

Abhinav1217

I added ash as tag because we are planning to use it for this feature, Its still on design phase so not much has been added as of yet. This was just some attempt to check if its possible to safely maintain single source of truth for db schema.

I will try your method today and let you know.. Thanks.

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
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
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
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40082 209
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement