exercism / exercism/website

ActiveRecord::InvalidForeignKey: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`exercism`.`solution_tags`, CONSTRAINT `fk_rails_162648ec79` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)) (ActiveRecord::InvalidForeignKey)

Open
#9,445 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
548
Forks
168
Avg merge
1d 8h
Merged PRs (30d)
22

Description

## Error

```
Cannot delete or update a parent row: a foreign key constraint fails (`exercism`.`solution_tags`, CONSTRAINT `fk_rails_162648ec79` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)) (Mysql2::Error)
```

## Stack trace

```
mysql2/client.rb:151 in _query
mysql2/client.rb:151 in block in Mysql2::Client#query
mysql2/client.rb:150 in Thread.handle_interrupt
mysql2/client.rb:150 in query
active_record/connection_adapters/mysql2/database_statements.rb:100 in block (2 levels) in ActiveRecord::ConnectionAdapters::Mysql2::DatabaseStatements#raw_execute
active_record/connection_adapters/abstract_adapter.rb:1027 in block in ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection
active_support/concurrency/null_lock.rb:9 in synchronize
active_record/connection_adapters/abstract_adapter.rb:999 in with_raw_connection
active_record/connection_adapters/mysql2/database_statements.rb:98 in block in ActiveRecord::ConnectionAdapters::Mysql2::DatabaseStatements#raw_execute
active_support/notifications/instrumenter.rb:58 in instrument
```

## Tracking Details
- **Project**: exercism-rails
- **Sentry**: [ActiveRecord::InvalidForeignKey: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`exercism`.`solution_tags`, CONSTRAINT `fk_rails_162648ec79` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)) (ActiveRecord::InvalidForeignKey)](https://thalamus-ai.sentry.io/issues/143539108/)
- **Culprit**: SettingsController#destroy_account
- **First seen:** Aug 28, 2026

Contributor guide

Open the contributing guide

Research direction

Start at SettingsController#destroy_account and use the linked Sentry report to reproduce or trace the account-deletion path. Read the MySQL foreign-key error involving solution_tags.user_id and users.id, then determine the deletion behavior that prevents the constraint failure. Done means account deletion no longer raises ActiveRecord::InvalidForeignKey.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, ruby
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.