Nightly job: clean up what's gone stale
The sessions table holds user sessions. Each one has a started_at start moment and an expires_at expiry. A nightly job purges the expired ones — their expiry is already in the past.
Delete from sessions every row whose expires_at is less than the current moment. Then return id, user_id of the remaining sessions, ordered by id.
Just INSERT/UPDATE/DELETE — no trailing SELECT needed.
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inFocus radio
Paused · SomaFM · Fluid