All of the upgrade methods I have seen (not sure about the magento connect method) do not touch the database only the files and & directories). I am on my first Magento build but I see that they have changed the directory structure with past updates. So my question is how should I update Magento to ensure the database gets upgraded?
As per @Anton's answer, the database upgrades are applied by the PHP code in the Magento modules themselves.
If you look in any of the code modules (say DOCROOT\app\code\core\Mage\Catalog\
for example), you will see a folder called sql\modulename_setup
which contains numerous files that perform the database upgrades relevant to their module version.
Note that the module version (specified in the etc/config.xml
for that module) will not always match the overall Magento version, though for some of the major modules such as Mage_Catalog, they are fairly close.
When you upload the new code onto your webserver's filesystem, the next time that you load any Magento page, the system will check the current database version number using the core_resource
table in mysql. If it is less than the version listed in that module's config.xml
, then Magento will apply the files in the sql\modulename_setup
folder in sequence to bring the data_version
up to match the module's version
.
The files under the sql
folder often contain both DDL and DML statements, and may be responsible for changing table structure, keys, relationships and inserting fixture data.
So, the short answer to your question "How do you update" is to let Magento do the update for you. Trying to manually recreate all those queries would be a recipe for disaster, particularly given the interdependencies between modules.
One important note - make sure you backup your database before upgrading!!!
A process we've used that works:
This way you keep all order/product/customer/etc data.
Of course, you'll need to ensure your modules and themes work with the new version of Magento first, and the usual caveats for 'backup first' etc etc...
If you upgrade magento :
database upgrades are handled by versions setup scripts
To illustrate this:
Now you can make a shell or python , ruby or whatever script to automate this for you. My experience says that all this (with generating magento repos, copying live database to dev, rsyncing needed files, upgrading in a loop) will take less tan 5 mins from 1.3.2.4 to 1.5.0.1 if automated
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With