Skip to content

Instantly share code, notes, and snippets.

@tarky
Created April 6, 2015 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarky/fb16bcf704db4b09257f to your computer and use it in GitHub Desktop.
Save tarky/fb16bcf704db4b09257f to your computer and use it in GitHub Desktop.
foreign key error
u.destroy
(0.2ms) BEGIN
Authentication Load (0.5ms) SELECT `authentications`.* FROM `authentications` WHERE `authentications`.`user_id` = 5
SQL (2.3ms) DELETE FROM `authentications` WHERE `authentications`.`id` = 4
Twitter Load (3.2ms) SELECT `twitters`.* FROM `twitters` WHERE `twitters`.`id` = 3 LIMIT 1
SQL (1.7ms) DELETE FROM `twitters` WHERE `twitters`.`id` = 3
Follow Load (0.3ms) SELECT `follows`.* FROM `follows` WHERE `follows`.`user_id` = 5
Activity Load (0.4ms) SELECT `activities`.* FROM `activities` WHERE `activities`.`trackable_id` = 16 AND `activities`.`trackable_type` = 'Follow' LIMIT 1
Feed Load (1.0ms) SELECT `feeds`.* FROM `feeds` WHERE `feeds`.`activity_id` = 40
Notification Load (0.4ms) SELECT `notifications`.* FROM `notifications` WHERE `notifications`.`activity_id` = 40
SQL (0.3ms) DELETE FROM `notifications` WHERE `notifications`.`id` = 24
SQL (1.8ms) DELETE FROM `activities` WHERE `activities`.`id` = 40
SQL (0.7ms) DELETE FROM `follows` WHERE `follows`.`id` = 16
Follow Load (0.4ms) SELECT `follows`.* FROM `follows` WHERE `follows`.`followed_id` = 5
SQL (11.2ms) DELETE FROM `users` WHERE `users`.`id` = 5
Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`inq_development`.`notifications`, CONSTRAINT `fk_rails_c3860515c7` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)): DELETE FROM `users` WHERE `users`.`id` = 5
(0.5ms) ROLLBACK
ActiveRecord::StatementInvalid: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`inq_development`.`notifications`, CONSTRAINT `fk_rails_c3860515c7` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)): DELETE FROM `users` WHERE `users`.`id` = 5
from /Users/araky/git/inq_rails/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `query'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment