How to save some time when upgrading Prestashop?
I like Prestashop and I always recommend it for people who wants build own shop online. But to keep it up to date might be tricky. Here is one tip which might help someone to make updates faster.
This is a module made by core team of Prestashop. This is my primary choice when it comes to upgrading between minor versions of the engine. It does the job almost perfectly – makes a backup of database and files, runs all the updates and You are ready to go very fast unless… Your website is old and database has some huge tables on it. Even for very simple shops that might be the case after running the shop for few years.
But how it is possible? I am not adding new products daily…
Prestashop is smart – it wants to make some statistics, maybe also calculate some forecasts of Your visitors and sales too. And there is no way to predict something if You do not have some starting data. So here is Your answer – some user visits and actions on the page makes Your shop’s database grow. And if You are running Your shop on some shared hosting then backup of the database becomes slow.
What can we do to make it faster?
That is why I am sharing this tip with You. There are three tables which grows by every users visit – connections, connecntions_source and guest.
And trick is very simple – make those tables smaller while updating. And of course there are many ways to do it. But I love this method – easy to understand, hard to fail and it does the job.
Step 1: rename tables with something like old_…. Prestashop uses prefixes, so it is a nice hack – if the prefix is different the 1-click update won’t touch it. And the SQL queries is very simple. If You do not know what a hell is SQL and how to use it then it is time to stop reading this article.
Else here You go:
RENAME TABLE ps_connections to old_ps_connections; RENAME TABLE ps_connections_source to old_ps_connections_source; RENAME TABLE ps_guest to old_ps_guest;
Step2: make empty copy of original tables
CREATE TABLE ps_connections LIKE old_ps_connections; CREATE TABLE ps_connections_source LIKE old_ps_connections_source; CREATE TABLE ps_guest LIKE old_ps_guest;
Step3: now it is time to run 1-click upgrade. I will not explain how it works and how to use it, I am sure there are a lot of information on the internet.
Step4: hopefully Your update run much faster now and now it is time to get Your data back. You can try to run these query one at the time – it can take some time and can make Your server busy. That IGNORE keyword can be skipped, but it allows that same query to be run again – basically it will ignore any existing records and move on.
INSERT IGNORE INTO ps_connections SELECT * FROM old_ps_connections; INSERT IGNORE INTO ps_connections_source SELECT * FROM old_ps_connections_source; INSERT IGNORE INTO ps_guest SELECT * FROM old_ps_guest;
Step5: verify if Your site is working as expected and if so then it is perfect time to get rid of temporary tables
DROP TABLE old_ps_connections_source; DROP TABLE old_ps_connections; DROP TABLE old_ps_guest;
That’s it. This tip saved me at least an hour on my last update and it was used while upgrading Prestashop 184.108.40.206 to 220.127.116.11.
WARNING: Don’t forget to make any backup before trying all of it – I am not responsible for any data loss You can run into during the procedure.