WIP: Add abandoned_usernames table#14069
Conversation
There was a problem hiding this comment.
This probably shouldn't be merged to main until the full patch series is ready.
I'm a bit hesitant to merge a new database table without it being used by anything, so yeah, I agree that we should probably wait with this until there is an actual user for this table.
| adopted_by INTEGER | ||
| CONSTRAINT fk_abandoned_usernames_adopted_by | ||
| REFERENCES users | ||
| ON DELETE SET NULL, |
There was a problem hiding this comment.
just for context: currently we don't delete any users, we only set their username to "ghost" and delete all the personal information from their account. I guess technically the ON DELETE SET NULL shouldn't be necessary since we never delete. I currently don't remember what the default behavior is when you don't specify it. Does it prevent the user from getting deleted then? 🤔
There was a problem hiding this comment.
I currently don't remember what the default behavior is when you don't specify it. Does it prevent the user from getting deleted then?
Yeah, unless it has the ON DELETE clause, a foreign key constraint like this prevents dropping the referenced rows.
currently we don't delete any users, we only set their username to "ghost" and delete all the personal information from their account.
Ah, got it, thanks. Would your preference be to take out the ON DELETE SET NULL here, since it shouldn't matter? Alternatively I could just put in a comment saying that this is never expected to happen in normal circumstances.
|
Thanks for your comments @Turbo87, I appreciate your time! I'll make the changes now, but will hold off on marking this as ready for review until discussion in the parent issue is complete, and I have the complete patch set ready. |
8cedad5 to
76c4dc0
Compare
76c4dc0 to
b968b32
Compare
This is the 1st of 2 prs to implement #13766. This probably shouldn't be merged to main until the full patch series is ready.
This PR adds the "abandoned_usernames" table, which will be used to track usernames that were once in "adopted" by an active user but were later "abandoned" (due to a username change or account deletion). The content of the table is based on the
deleted_cratestable, including anavaliable_atfield for a cooldown period before the username can be used again.(FYI, in the diff, it looks like
diesel print-schemaseems to have swapped the order ofreadme_renderingsandrecent_crate_downloadsinschema.rs, I'm not quite sure why.)