SHARE
TWEET

Untitled

a guest Nov 29th, 2019 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. eirb(main):115:0> User.joins(roles: :permissions).where(email: target_user_emails.map(&:downcase), roles: { active: true }, permissions: { name: 'ticket.customer', active: true }.where.not(id: 1).find_each do |user|
  2. irb(main):116:1*
  3. #irb(main):117:1*  puts "Customer #{user.login}/#{user.email} has #{Ticket.where(customer_id: user.id).count} tickets"
  4.  
  5.  
  6.  
  7.  Tirb(main):118:1>
  8. iirb(main):119:1>
  9. irb(main):120:1>
  10. irb(main):121:1>  Ticket.where(customer: user).find_each do |ticket|
  11.  
  12.    irb(main):122:2*
  13. irb(main):123:2*    puts "  Deleting ticket #{ticket.number}..."
  14. irb(main):124:2>
  15. irb(main):125:2>    ticket.destroy
  16. irb(main):126:2>
  17. irb(main):127:2>  end
  18.  irb(main):128:1>
  19. irb(main):129:1>
  20. irb(main):130:1>
  21. irb(main):131:1>  puts "  Removing references for user with E-Mail #{user.email}..."
  22.  
  23.  Actirb(main):132:1>
  24. iviirb(main):133:1>  ActivityStream.where(created_by_id: user.id).update_all(created_by_id: 1)
  25. irb(main):134:1>
  26. irb(main):135:1>  History.where(created_by_id: user.id).update_all(created_by_id: 1)
  27. irb(main):136:1>
  28. irb(main):137:1>  Ticket::Article.where(created_by_id: user.id).update_all(created_by_id: 1)
  29. irb(main):138:1>
  30. irb(main):139:1>  Ticket::Article.where(updated_by_id: user.id).update_all(updated_by_id: 1)
  31. irb(main):140:1>
  32. irb(main):141:1>  Store.where(created_by_id: user.id).update_all(created_by_id: 1)
  33. irb(main):142:1>
  34. irb(main):143:1>  StatsStore.where(created_by_id: user.id).update_all(created_by_id: 1)
  35. irb(main):144:1>
  36. irb(main):145:1>  Tag.where(created_by_id: user.id).update_all(created_by_id: 1)
  37. irb(main):146:1>
  38. irb(main):147:1>  if OnlineNotification.find_by(user_id: user.id)==""
  39. irb(main):148:2>
  40. irb(main):149:2>   OnlineNotification.find_by(user_id: user.id).destroy!
  41. irb(main):150:2>
  42. irb(main):151:2>  end
  43. irb(main):152:1>
  44. irb(main):153:1>
  45. irb(main):154:1>
  46. irb(main):155:1>  puts "  Deleting user #{user.login}/#{user.email}..."
  47.  
  48.  useirb(main):156:1>
  49. rirb(main):157:1>  user.destroy
  50. irb(main):158:1>
  51. endirb(main):159:1> end
  52. Customer auto-1574873834-256835/fakeemail@gmail.com has 1 tickets
  53.   Deleting ticket 46080...
  54. Ticket::Article.find(1280) notify DESTOY 2019-11-27 11:44:07 UTC
  55. Ticket.find(81) notify UPDATED 2019-11-29 16:03:38 UTC
  56. User.find(366) notify TOUCH 2019-11-29 16:03:38 UTC
  57. Ticket::Article.find(1281) notify DESTOY 2019-11-27 11:44:09 UTC
  58. Ticket.find(81) notify TOUCH 2019-11-29 16:03:38 UTC
  59. Ticket.find(81) notify DESTOY 2019-11-29 16:03:38 UTC
  60. User.find(366) notify TOUCH 2019-11-29 16:03:38 UTC
  61.   Removing references for user with E-Mail fakeemail@gmail.com...
  62.   Deleting user auto-1574873834-256835/fakeemail@gmail.com...
  63. Traceback (most recent call last):
  64.         2: from (irb):115
  65.         1: from (irb):157:in `block in irb_binding'
  66. ActiveRecord::StatementInvalid (Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`zammad`.`users`, CONSTRAINT `fk_rails_45307c95a3` FOREIGN KEY (`created_by_id`) REFERENCES `users` (`id`)): DELETE FROM `users` WHERE `users`.`id` = 366)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top