<rpifan>
ive got a bunch of random bad users but at least i know now
<rpifan>
ok that user is gone
<rpifan>
ok sigh a whole bunch of stuff references that one user
<rpifan>
turns out only that users it own id self rered
<rpifan>
cool
<rpifan>
im more familiar with sql
<rpifan>
ah
<rpifan>
yourmodel?
<rpifan>
how can i updated the created by colum to that number for all the other users
<rpifan>
ok so the real admin user is 141
<NL3limin4t0r>
rpifan: But yeah, all records that point to that user have to be updated if you're planning to delete the user.
<NL3limin4t0r>
rpifan: You could for example add a "disabled_at" column that is set when a user is disabled.
<NL3limin4t0r>
rpifan: A better option might be to disable users instead of simply deleting the entrire record. This allows other records to still point to them.
<rpifan>
or is that command going to update all the user created by entries
<rpifan>
wont that destroy all the otehr links
<rpifan>
hmm im thinking now if i delet ethis user 366 it seems to be the created of all users
<NL3limin4t0r>
rpifan: UPDATE `table_name` SET `column_name` = 1234 WHERE `table_name`.`id` = 1234
<rpifan>
so how do i do that in mysql set created_by_id = 256
<rpifan>
?
<rpifan>
yea i got it
<havenwood>
rpifan: It's a multi-codepoint Emoji.
<rpifan>
ahh
<havenwood>
rpifan: that sounds reasonable. 👍🏽
<rpifan>
and then delete it
<rpifan>
so can i change the created by id to 256
<rpifan>
but it was updated by id 266
<rpifan>
it is id 366 but it says it was also created by id 366
<rpifan>
i think i understand
<NL3limin4t0r>
rpifan: aka your current schema does allow NULL values in that column.
<rpifan>
created_by_id | int(11) | NO | MUL | NULL
<NL3limin4t0r>
rpifan: That depends what the referencing record is. If it's an important record you might not want to delete it. You could also migrate the records that point to the user you want to delete, and let them point to the system user instead.
<rpifan>
NL3limin4t0r, i found a refende to id 366 should i just delete the entry from the db?
<rpifan>
so i read the previous stuff and found a table called users
<NL3limin4t0r>
rpifan: Last time you posted this link: https://pastebin.com/8pcTq0AD which says that the foreign key "fk_rails_45307c95a3" is blocking the deletion because some "created_by_id" column is still refereing to the user id.
<havenwood>
rpifan: There's a #created_by_id reference to another User id—that's the foreign key.
<rpifan>
well where do i find this foreign key
<NL3limin4t0r>
rpifan: Running `as_array(data)` results in the same output for both inputs.
<rpifan>
NL3limin4t0r, i got into the db how do i find the missing table
<rpifan>
now i know its all in mysql
<rpifan>
if i nullify the association wont i break it?
<rpifan>
so its basically saying there is something in the database that is still refering ot the user?
<NL3limin4t0r>
rpifan: It's not to hard, you just have some foreign key constraint blocking the deletion of a record. If you find out which record refers to the user and remove that record, or nullify the association you should be good.
<rpifan>
so im just gonna solve it myself
<rpifan>
so the zammad ppl didnt help
<NL3limin4t0r>
rpifan: hey
<rpifan>
NL3limin4t0r, hello
<rpifan>
hello
2019-11-29
<rpifan>
thanks
<rpifan>
oh well
<rpifan>
well nice weekend y'all. i gotta come in to work tommorow to do redo the network rack
<rpifan>
yea thats true, i had hoped this owuld be a set it and forget it kind of deal but i see its not. At least it gives me something to work on when im bored at wokr
<rpifan>
i really appreacite y'all help in gettin gme ot understand a littel bit more how this set up works. I'm not even sure how to log into the db as it was all setup by the zamad script
<rpifan>
its ok i just wrote on the zammad support forum
<NL3limin4t0r>
rpifan: You can find out which table has issues with the deletion of a user with the following query: SELECT * FROM information_schema.table_constraints WHERE `CONSTRAINT_SCHEMA` = 'database name' AND `CONSTRAINT_NAME` = 'fk name'
<rpifan>
and it still has that issue
<rpifan>
i just purged all the tickets just in case
<rpifan>
so i would delete the records in mysql or the records in the main system
<NL3limin4t0r>
rpifan: Although deleteing the foreign key is certainly an option, I personally wouldn't recommend it. Check in you database whate reference the fk_rails_45307c95a3 foreign key validates, there might still be some records pointing to the user.
<havenwood>
rpifan: They say in that ticket to remove or reassign any references. So here, you'd need to reassign. the created_by_id before deleting this person.
<havenwood>
rpifan: There's a #created_by_id reference to another User id—that's the foreign key.
<rpifan>
its zammad
<rpifan>
since im just using this app
<rpifan>
idk what exactly that means
<rpifan>
i just want to delet that user
<havenwood>
rpifan: You can remove foreign key constraints you don't want.
<havenwood>
rpifan: Do you want that constraint ensuring there's a valid foreign key?
<rpifan>
oh
<ruby[bot]>
rpifan: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com