I tried step-1 to step-3 in the link (https://docs.zammad.org/en/latest/admin/console/dangerzone-for-experts.html#deleting-customers) and I got an error as shown below.
I try to remove the user directly by User.find(3).destroy(), but no luck to delete it. Could you get any clue out of it?
$ sudo zammad run rails c
Loading production environment (Rails 5.2.4.1)
irb(main):001:0> User.find(3)
=> #<User id: 3, organization_id: nil, login: “dinesh12@gmail.com”, firstname: “Dinesh”, lastname: “Admin”, email: “dinesh12@gmail.com”, image: nil, image_source: nil, web: “”, password: “$argon2id$v=19$m=65536,t=2,p=1$VorELCR1hVGERJRUVvv…”, phone: “”, fax: “”, mobile: “”, department: “”, street: “”, zip: “”, city: “”, country: “”, address: “”, vip: false, verified: false, active: false, note: “”, last_login: “2020-05-14 12:46:31”, source: nil, login_failed: 0, out_of_office: false, out_of_office_start_at: nil, out_of_office_end_at: nil, out_of_office_replacement_id: nil, preferences: {“notification_config”=>{“matrix”=>{“create”=>{“criteria”=>{“owned_by_me”=>true, “owned_by_nobody”=>true, “no”=>false}, “channel”=>{“email”=>true, “online”=>true}}, “update”=>{“criteria”=>{“owned_by_me”=>true, “owned_by_nobody”=>true, “no”=>false}, “channel”=>{“email”=>true, “online”=>true}}, “reminder_reached”=>{“criteria”=>{“owned_by_me”=>true, “owned_by_nobody”=>false, “no”=>false}, “channel”=>{“email”=>true, “online”=>true}}, “escalation”=>{“criteria”=>{“owned_by_me”=>true, “owned_by_nobody”=>false, “no”=>false}, “channel”=>{“email”=>true, “online”=>true}}}}, “locale”=>“en-us”, “intro”=>true, “tickets_closed”=>5, “tickets_open”=>5, “chat”=>{“active”=>{“1”=>“on”}}}, updated_by_id: 13, created_by_id: 1, created_at: “2020-01-21 15:27:30”, updated_at: “2020-07-20 13:21:41”>
irb(main):002:0> User.find(3).destroy()
curl -X delete “http://127.0.0.1:9200/zammad_production_stats_store/_doc/1”
200
Traceback (most recent call last):
1: from (irb):2
ActiveRecord::InvalidForeignKey (PG::ForeignKeyViolation: ERROR: update or delete on table “users” violates foreign key constraint “fk_rails_45307c95a3” on table “users”)
DETAIL: Key (id)=(3) is still referenced from table “users”.
: DELETE FROM “users” WHERE “users”.“id” = $1
Steps to reproduce the behavior:
- Create an account in Admin user management
- Create Tickets and assign the User
- Remove the Ticket and User