PrestaShop icon indicating copy to clipboard operation
PrestaShop copied to clipboard

Tool for check integrity of prestashop DB

Open Gipielle opened this issue 5 years ago • 8 comments

Is seems that prestashop autoupgrade module some time make mistake, i will aprociate a tool that checks if prestashop tables are set correctly, in case that in some upgrade some table was not setted propretly

Gipielle avatar Mar 08 '20 21:03 Gipielle

This is an example: https://github.com/PrestaShop/PrestaShop/issues/17880

Gipielle avatar Mar 08 '20 22:03 Gipielle

Is seems that prestashop autoupgrade module some time make mistake, i will aprociate a tool that checks if prestashop tables are set correctly, in case that in some upgrade some table was not setted propretly

Unfortunately this would be very hard to do because modules are able to modify the SQL schema so the tool would inform user about false issues. 😭

matks avatar Mar 09 '20 14:03 matks

OK but with a check tool you can have ad idea if something was not set correctly and then check is if caused by a module

Gipielle avatar Mar 10 '20 09:03 Gipielle

OK but with a check tool you can have ad idea if something was not set correctly and then check is if caused by a module

Yes and no ... 😥because PrestaShop is both a software ready-to-be-used and a development platform used by developers to build something on top of it. We have seen people rework the SQL schema for their specific needs. And if someone wants to modify how PrestaShop behaves, it's his full right as it's an open source software.

The only thing we could do in a reliable way would be to create a tool that would say "Your SQL schema is (or is not) compliant with PrestaShop standard structure for version X"

matks avatar Mar 11 '20 08:03 matks

Hello,

I try to explain better: let's admit that I don't use external prestashop modules and I want to know if the prestashop database structure is correct, a tool that does the checking would be useful.

If then I installed an external module and possibly the tool checks me and sees the modified tables I can go to see if they are related to that module.

But at least if I have not applied changes in prestashop I am sure that the database is intact, as I have seen several times the update procedures do not work very well and it may be that they do not update the tables. In this case a check of the tables would avoid hours of searching for errors..

Gipielle avatar Mar 11 '20 09:03 Gipielle

Ping @PrestaShop/prestashop-core-developers what do you think?

Thanks!

khouloudbelguith avatar Mar 25 '20 10:03 khouloudbelguith

It's a nice idea. Adding a tool that is able to compare the database structure and tell if:

  • fields are here with the right type & length
  • fields shouldn't be there
  • all tables are present

PierreRambaud avatar Nov 23 '20 15:11 PierreRambaud

If there is any vague issue create here on PrestaShop, you can say run psdatacheck module and send the report here.

There have been issues, like:

  • Modules adding columns to tables PrestaShop's native tables, which despite all the advice, still happens
  • Payment modules that fail and create an corrupt `ps_ordere_history, see #16657 and #19098
  • autoupgrade
  • Overrides that manipulate the data incorrectly

There are more ways to corrupt data... of course.

The tool could check if

  • relations exist in the database, like: ps_category.id_parent, ps_order_detail.id_order, ps_order_state.id_order_state
  • Columns match with the ObjectModel classes. Are any extra columns added? Does the character length match?

It might help a lot of the issues on GitHub that are not reproducible. The data structure might give a clue.

muyncky avatar Dec 18 '20 09:12 muyncky