Skip to content

Refactor database models and update foreign key constraints#1552

Open
LuisMend12 wants to merge 2 commits into
Valour-Software:mainfrom
LuisMend12:main
Open

Refactor database models and update foreign key constraints#1552
LuisMend12 wants to merge 2 commits into
Valour-Software:mainfrom
LuisMend12:main

Conversation

@LuisMend12
Copy link
Copy Markdown
Contributor

Bug
When attempting to delete certain bots, the deletion would silently fail or throw a database error. This happened because several foreign key constraints on related tables (messages, message reactions, user channel states, and eco accounts) were set to NO ACTION on delete. If a bot had any planet member activity — messages sent, reactions left, channel states recorded — the database would refuse to delete the bot's member record, blocking the entire deletion.

Fix
Updated the foreign key constraints on author_member_id and planet_member_id columns in the affected tables to use SET NULL on delete instead of NO ACTION. A database migration was added to apply these changes. Now when a bot is deleted, related records have their foreign key columns nulled out rather than preventing the operation.

Affected tables:

messages.author_member_id
message_reactions.author_member_id
user_channel_states.member_id
eco_accounts.planet_member_id

@LuisMend12 LuisMend12 requested a review from a team as a code owner May 12, 2026 02:45
@SpikeViper
Copy link
Copy Markdown
Member

Preferably we would actually wipe these things out prior to deleting the bot; deleting a user should delete that user's data, not leave it dangling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants