Clear data automatically
Is it possible to clear my database data automatically every night at midnight? We are running a showcase type app using our web framework, and want to clear data.
Also - with that being said, another user has "edit" access and they can do most everything else but can't wipe the volume.
We can do other things but I'm wondering if its available for us via the UI
https://fullstack.litestar.dev/
Solution:Jump to solution
users with edit permissions can't do destructive actions.
as for the wipe, you could write a script that uses the public api to wipe the volume of the database and then have railway run that as a cron job...
4 Replies
Project ID:
6f1f252f-a6f4-42ab-a5c7-6ba05c3f74de
6f1f252f-a6f4-42ab-a5c7-6ba05c3f74de
Solution
users with edit permissions can't do destructive actions.
as for the wipe, you could write a script that uses the public api to wipe the volume of the database and then have railway run that as a cron job
New reply sent from Help Station thread:
Postgresql?CREATE EXTENSION pg_cron;SELECT cron.schedule('clear_data', '0 0 * * *', $$DELETE FROM your_table_name;-- Add more SQL commands here if you need to clear data from multiple tables$$);-- Log + MonitorCREATE TABLE cron_log (log_time timestamp with time zone DEFAULT now(),message text);-- Update the cron job to log the outputSELECT cron.schedule('clear_data', '0 0 * * *', $$DELETE FROM your_table_name RETURNING 'Data cleared at ' || now();$$, 'INSERT INTO cron_log (message) VALUES ($1)');You're seeing this because this thread has been automatically linked to the Help Station thread.