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
Also Liked
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
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.
Popular in Discussions
Other popular topics
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









