I maintain a Django app with a postgresql backend. Users log in and exchange messages (forum style) with one another.
All users are identified by unique
usernames (saved in the
auth_user table), that also double up as
nicknames for the users when they interact with one another in the forum.
I want to delete/deprecate data of users who haven't logged a session in my web app since the past 3 months. I'm doing this in order to free up nicknames for new users. I.e. new users need to keep a nickname, and if one's taken, they are made to retry. So if I can get rid of old users, the average number of retries a new user has to do will go down too. I.e. it'll become easier for incoming newbies to register for my service. So that's my goal here.
Ideally, I would simply delete the required rows from
auth_user, however there are foreign key constraints that get violated (since
ON DELETE CASCADE is not set on them, most are
DEFERRABLE INITIALLY DEFERRED).
I was going to edit all these foreign key constraints and change them to
ON DELETE CASCADE. But before I do that, I wanted to get expert advice on whether that's my only option in the scenario I've described. I'll have to make changes to foreign keys in ~50 tables, and secondly,
ON DELETE CASCADE feels a bit too aggressive.