wallyfoo

wallyfoo

Ecto and postgres triggers -- Any resources for how to pull this off?

Long story short, I have a real world need to create a view for hooking up a shipping terminal to live data, but because of some early architecture decisions, using a view isn’t practical in this case. (The shipping software doesn’t do joins, only single table access, hence a view.)

I populated a lookup table with the data the shipping software needs, but if a customer changes their shipping information on their account, an update trigger to also update the associated lookup table seems smart. I have a solution that updates the data, but I would like the database to deal with itself rather than bolting logic onto the application.

Understanding that this isn’t a terribly common problem to solve, I’m not finding a lot of resources on how to deal with triggers with Ecto. The Little Ecto Cookbook, for instance, doesn’t seem to reference this sort of thing.

Anyone know of a good place to start with triggers and Ecto?

Most Liked

LostKobrakai

LostKobrakai

Besides migrations basically nothing of ecto cares or need to care about triggers. As for migrations there’s no ecto specific API for triggers so your only option is to use execute/2 to run raw sql. Given that context it makes sense that there’s not much documentation, as there’s actually nothing ecto specific to document in the first place. Take whatever resource you can find about the sql side of things and you should be able to put the sql into a migration to execute.

wallyfoo

wallyfoo

I should have been more clear in my explanation. I was looking at it from the migration end, so execute/2 to define the trigger is likely the way to go. This is precisely what I was looking for. Thanks!

Where Next?

Popular in Chat/Questions Top

pdgonzalez872
Do we have a list of academic/research papers: about Elixir/Erlang? that use Elixir/Erlang? about the Beam? If so, could you please po...
New
Fl4m3Ph03n1x
I am doing some exercises while learning Elixir using Exercism.io. Now, my objective is to do all exercises, extras included. This shoul...
New
Allyedge
Hey, I want to learn Elixir OTP and I wanted to know if there are any good resources that teach it. I found some web pages, but none of t...
New
RKC07
I’m new to elixir. I did some coding in python and C. I want to learn elixir for starting my career in web development. I need suggestion...
New
New
shansiddiqui94
Hello all, I recently did my first app in Phoenix and Liveview, many thanks to all the users who assisted me. I found that the tutorial ...
New
wolfiton
Hi everyone, How can i retrieve the name from a structure like this? %{"id" => "1570", "name" => "Croque Monsieur"} My test loo...
New
eliottramirez
Hello, I’m trying to learn Phoenix but I constantly find difficult understanding how the framework works, and I think part of this is th...
New
boddhisattva
Greetings everyone, At my current workplace we’re evaluating different ways of building a microservices architecture for some parts rela...
New
Nopp
Hey guys and girls, i am completely “new” to programming, recently played a bit with Python, Ruby and PureBasic, but i want to try somet...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
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
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
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
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
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
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

Latest on Elixir Forum

We're in Beta

About us Mission Statement