Page 1 of 1
[SOLVED] Safe to delete customers directly in the database?
Posted: Wed Jan 11, 2023 12:28 am
by tom327
I had hundreds of spam customer registrations and want to delete them.
Is it safe to delete customers directly in the Opencart database, without causing any issuers, errors, or messing things up?
I see there is a table named OC _Customer
My fear is there are connected tables to this one and just deleting rows form this table will cause some error.
Re: Safe to delete customers directly in the database?
Posted: Wed Jan 11, 2023 1:12 am
by Durango95
Hello Tom327,
It's not the best thing to do.
In addition to the oc_customer table, there are 14 more tables related to the customer table.
By deleting these items directly in the oc_customer table, you will keep the relational records in the other tables. You can delete the customer and all relationships through the customer record itself.
tom327 wrote: ↑Wed Jan 11, 2023 12:28 am
I had hundreds of spam customer registrations and want to delete them.
Is it safe to delete customers directly in the Opencart database, without causing any issuers, errors, or messing things up?
I see there is a table named OC _Customer
My fear is there are connected tables to this one and just deleting rows form this table will cause some error.
Re: Safe to delete customers directly in the database?
Posted: Wed Jan 11, 2023 3:01 pm
by OSWorX
Durango95 wrote: ↑Wed Jan 11, 2023 1:12 am
It's not the best thing to do.
In addition to the oc_customer table, there are 14 more tables related to the customer table.
Only partly correct.
If those "customers" registered themselves only, they can be simply deleted without any side affect.
Either through the shop backend or directly in the database.
Re: Safe to delete customers directly in the database?
Posted: Wed Jan 11, 2023 6:09 pm
by paulfeakins
OSWorX wrote: ↑Wed Jan 11, 2023 3:01 pm
If those "customers" registered themselves only, they can be simply deleted without any side affect.
Either through the shop backend or directly in the database.
Are you sure it doesn't add any related records in that case? What about address?
Anyway, to avoid these, you could consider our extension:
https://www.opencart.com/index.php?rout ... er=antropy
Re: Safe to delete customers directly in the database?
Posted: Wed Jan 11, 2023 7:21 pm
by JNeuhoff
As others have said, it's not enough to delete customer from the oc_customer. You'd also have to delete records with identical customer_id from these tables:
oc_address
oc_cart
oc_coupon_history
oc_customer_activity
oc_customer_affiliate
oc_customer_approval
oc_customer_history
oc_customer_ip
oc_customer_online
oc_customer_reward
oc_customer_transaction
oc_customer_search
oc_customer_wishlist
oc_order
oc_return
oc_review
If you are getting many fake account registrations, you can use our
SpamBot Buster to prevent this from happening.
Re: Safe to delete customers directly in the database?
Posted: Wed Jan 11, 2023 7:52 pm
by OSWorX
paulfeakins wrote: ↑Wed Jan 11, 2023 6:09 pm
OSWorX wrote: ↑Wed Jan 11, 2023 3:01 pm
If those "customers" registered themselves only, they can be simply deleted without any side affect.
Either through the shop backend or directly in the database.
Are you sure it doesn't add any related records in that case? What about address?
Yes, I am sure.
Right now tested and customer AND address is deleted when I delete those "customers" through the backend.
And as I said:
IF they made no orders, removing them by doing as described above, works and need no additional extensions - sorry.
Re: Safe to delete customers directly in the database?
Posted: Thu Jan 12, 2023 1:22 am
by paulfeakins
OSWorX wrote: ↑Wed Jan 11, 2023 7:52 pm
through the backend.
Then you misunderstood as the OP was talking about removing them from the database directly.
tom327 wrote: ↑Wed Jan 11, 2023 12:28 am
Is it safe to delete customers directly in the Opencart database
Re: Safe to delete customers directly in the database?
Posted: Thu Jan 12, 2023 5:47 pm
by OSWorX
paulfeakins wrote: ↑Thu Jan 12, 2023 1:22 am
OSWorX wrote: ↑Wed Jan 11, 2023 7:52 pm
through the backend.
Then you misunderstood as the OP was talking about removing them from the database directly.
tom327 wrote: ↑Wed Jan 11, 2023 12:28 am
Is it safe to delete customers directly in the Opencart database
Maybe ..
That's why I wrote that both methods will delete such fake registrations.
When done dircectly in the database (whikle I do not see any reason why doing so because it works perfectly when deleting them in the backend), the address table has to be cleaned also.
Which require an additional step, because those records deleted in the customer table has to be recorded (write in sheet e.g.) and then used to delete the address records.
Deleting fake customer through the backend require 1 step, doing it in the database 3 steps.
Selling extensions is one, but only when really needed ..
Re: Safe to delete customers directly in the database?
Posted: Thu Jan 12, 2023 10:14 pm
by paulfeakins
OSWorX wrote: ↑Thu Jan 12, 2023 5:47 pm
Deleting fake customer through the backend require 1 step, doing it in the database 3 steps.
But you can delete hundreds with one query ...
Re: Safe to delete customers directly in the database?
Posted: Thu Jan 12, 2023 10:57 pm
by OSWorX
paulfeakins wrote: ↑Thu Jan 12, 2023 10:14 pm
OSWorX wrote: ↑Thu Jan 12, 2023 5:47 pm
Deleting fake customer through the backend require 1 step, doing it in the database 3 steps.
But you can delete hundreds with one query ...
Increasing the admin list limit to x (for this task) will also delete finally hundreds
I guess we can say: OPs question is answered ..
Better for him to install an extension to avoid such registrations.
Re: Safe to delete customers directly in the database?
Posted: Fri Jan 13, 2023 12:36 am
by paulfeakins
Yes, good solutions indeed.