KiKi

KiKi

Update postgres field on date

Hi,

what would be the best way to update database field on a specific date? For an example, a project has a db fields status, start_date and end_date. When project is created, status is set to “active”, start_date is created and end_date is set to 30 days later. Now, how to update status to “inactive” on end_date automatically after 30 days? Should I create a cron job, it won’t do it at exact time but it will be close at least, or is there a better way?

Marked As Solved

dimitarvp

dimitarvp

You could always use Oban?

Also Liked

KiKi

KiKi

Hi, if you can still remodel that table, consider using only start and end columns. Then create a view with status column derived from both dates.

This would be the easiest way but some business logic depends on that field so it’s not really a viable solution in this situation, but thanks anyway.

You could always use Oban?

I wasn’t aware of Oban before, this could solve the problem I have here and a couple of others too. Thanks for pointing me to it.

Last Post!

KiKi

KiKi

Hi, if you can still remodel that table, consider using only start and end columns. Then create a view with status column derived from both dates.

This would be the easiest way but some business logic depends on that field so it’s not really a viable solution in this situation, but thanks anyway.

You could always use Oban?

I wasn’t aware of Oban before, this could solve the problem I have here and a couple of others too. Thanks for pointing me to it.

Where Next?

Popular in Discussions Top

ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement