DEV Community

Abhinav Kulshreshtha
Abhinav Kulshreshtha

Posted on

HELP: Pull schema updates from postgres into elixir app

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 schema would be full access schema for elixir service.

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 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.

Top comments (0)