Deleting aged postgresql rows with foreignkey constraints
First start a transaction:

begin;


Start deleting all from links_groupseen first:

delete 
from links_groupseen 
where which_reply_id in (select myproperid from links_reply where "submitted_on" &lt; now() - interval '30 days')


and then delete from links_reply:

DELETE 
FROM links_reply 
WHERE "submitted_on" &lt; now()- interval '30 days';


and if you're happy with what you see, you can COMMIT. The reason I'm using a transaction is that within a transaction, now() will give you the same values at each call. Otherwise, you would have to replace now with a constant MYDATE value of your choice on both delete statements.