Hello, I'm new to working with a database like sup...
# help
d
Hello, I'm new to working with a database like supabase and I'm wondering how can I update all (replace with a different value) rows from specific column in a table every 24 hours? (I'm possibly looking for a SQL query solution)
n
Hello @dope! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
You will need to use the pg_cron extension. https://supabase.com/blog/2021/03/05/postgres-as-a-cron-server Then you can put your sql code to update the table rows where it says put your code between....
Copy code
select
  cron.schedule(
    'cron-name', -- name of the cron job
    '* * * * *', -- every minute
    $$
     -- Put your code between two dollar signs so that you can create full statements.
     -- Alternatively, you can write you code in a Postgres Function and call it here.
    $$
  );
n
dope (2022-04-15)
d
Copy code
select
  cron.schedule(
    'update-mods',
    '* * * * *',
    $$
    update testtable set kek = 'lppl'
    $$
  );
is this right? cause it doesn't seem to update the value every minute
g
You might need to add 'where true' to that as Supabase has an extension installed to prevent people from accidentally wiping out their table with updates without a 'where' clause.
d
it worked! thank you so much!
n
Thread was archived by @dope. Anyone can send a message to unarchive it.