3

I am looking for an organised way to run joomla updates locally and then update production systems by means of code deployment + db migrations, so that i do not have to update joomla on production, or disable the site while running updates. The current update component uses a specific function to run sql updates

https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_joomlaupdate/models/default.php#L515

In finaliseUpgrade it looks like it is fetching/parsing some queries and applying them to the schema. If i understand this correctly it loops through the scripts/place holders in com_admin/sql/{DBType}/*.sql detecting all the new versions of sql files it has to run on the db.

The problem with these scripts is that I do not see how i can use them as a migration tool for my production database as they are table prefixed and also I would much rather have a single consolidated migration script.

Could you suggest if joomla actually writes the changes it performed somewhere in a migration file?

The logs/joomla_update.php file contains some traces of the changes but these are truncated as apparently it records only a few characters

Any suggestion is very much appreciated.

3
  • I would also like migration files, as thats what we add to git when building external parts. Jun 2, 2014 at 16:09
  • Are you looking for data migrations, rather than table changes, as these should be done in extension updates. For data there doesn't seem a clean way Jun 2, 2014 at 16:11
  • @tristanbailey i am mainly focusing on joomla updates right now, being small versions, patches or major versions updates. For instance 2.5.x to 3.x. The suggestion from Riccardo might be what i am looking for though as far as i remember when going to the new website code i could not access the administration, but i will git it another try.
    – Bizmate
    Jun 5, 2014 at 0:05

1 Answer 1

1

Two scenarios:

Development, Staging-Authoring, Production

Production is read-only, Staging is where content is prepared and tests are made. Joomla is always updated on Staging, then the db is saved along with the commit, and restored on pull in production.

Development, Staging, Production

Contents are edited on Production. Joomla updates are performed on Staging. Once you push them, just go to extensions/database and press Fix. Or, for larger servers, automate it with a system plugin (write a plugin that listens for some param in onAfterRoute, check if it's a local call ($_SERVER['REMOTE_ADDR']='127.0.0.1' and schedule a cron job to invoke it).

Update

To perform the db updates after each version upgrade, you have two ways:

Automatic

Go to administrator - extensions - extension manager, click database on the left, and click "Fix" on top.

If this page has errors (the case when upgrading from 2.5 to 3.3), try going directly to the url:

/administrator/index.php?option=com_installer&view=database

Manual

When the above fails, (see also @Diego's comment below):

 find administrator/components/com_admin/sql/updates/mysql/3*.sql | grep mysql > 33.listsql

and fitler out the relevant files (the versions affected are in the filename)

Then, provided j25 is your db prefix

cat 33.listsql | xargs cat > 33.sql
sed -i 's/#_/j25/' 33.sql
mysql -u user --password="somepass" dbname < 33.sql
4
  • I am using Development, Staging, Production, i just copied my production db to staging and the development code updates (mainly joomla 2.5 to 3.3.1 with some template fixes) have been now pushed to staging. When i access the administrator path a failure page is shown saying Table .j25_postinstall_messages' doesn't exist SQL=SHOW FULL COLUMNS FROM j25_postinstall_messages Any alternative to copying the post install table from development to staging?
    – Bizmate
    Jul 8, 2014 at 0:20
  • yes I added a final section to my answer. Jul 8, 2014 at 6:30
  • I thought of using those files but it just does not feel like a structured approach to manually create your own migration. Anyway for the benefit of anyone reading the actual steps should be find administrator/components/com_admin/sql/updates/mysql/3*.sql | grep mysql | xargs cat > 33.sql sed -i 's/#_/j25/' 33.sql where j25 is just my db prefix
    – Bizmate
    Jul 8, 2014 at 23:07
  • good point I forgot the prefix replace, I'll update the answer with your suggestion + add the administrator path that sometimes could work Jul 10, 2014 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.