Forums | Mahara Community
Support
/
Upgrade from 15.04.4 to 15.10.0 Fails
23 November 2015, 14:34
I'm attempting to upgrade to Mahara 15.10.0 and early into the upgrade database I get the following error. Can anyone help with this? Should I even attempt to update the database row myself? I'm using mysql version 5.6.20 on php version 5.5.27
Thanks in advance. Looking forward to the new theme system, so I hope I can get this working.
Bill Warters
Error updating core:
Failed to get a recordset: mysqli error: [1452: Cannot add or update a child row: a foreign key constraint fails ("maharadb"."view", CONSTRAINT "view_own_fk" FOREIGN KEY ("owner") REFERENCES "usr" ("id"))] in adodb_throw(INSERT INTO "view" ("title", "description", "owner", "ctime", "mtime", "atime", "numrows", "numcolumns", "template", "copynewuser", "type", "urlid", "anonymise") VALUES ('Untitled', 'Set up the default layout for the pages that your users create. You can also add blocks. Please note that any content you add to the default page will appear on every page that your users create.', 0, '2015-11-22 20:12:40', '2015-11-22 20:12:40', '2015-11-22 20:12:40', 1, 2, 1, 0, 'portfolio', 'untitled', 0), ) Command was: INSERT INTO "view" ("title", "description", "owner", "ctime", "mtime", "atime", "numrows", "numcolumns", "template", "copynewuser", "type", "urlid", "anonymise") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and values was (Untitled,Set up the default layout for the pages that your users create. You can also add blocks. Please note that any content you add to the default page will appear on every page that your users create.,0,2015-11-22 20:12:40,2015-11-22 20:12:40,2015-11-22 20:12:40,1,2,1,0,portfolio,untitled,0)
- insert_record("view", object(stdClass), "id", true) at myserverpathfolio/lib/view.php:732
View->commit() at myserverpathfolio/lib/view.php:706
View->__destruct() at myserverpathfolio/lib/view.php:331
View::_create(array(size 5), 0) at myserverpathfolio/lib/view.php:331
View::create(array(size 5)) at myserverpathfolio/lib/view.php:6622
install_system_portfolio_view() at myserverpathfolio/lib/db/upgrade.php:4204
xmldb_core_upgrade("2015030419") at myserverpathfolio/lib/upgrade.php:359
upgrade_core(object(stdClass)) at myserverpathfolio/admin/upgrade.json.php:90
23 November 2015, 16:38
Hi Bill,
Normally at installation, Mahara creates an invisible "root" user with id=0 and username=root, in the Mahara database's "usr" table. Among other things, the default page templates have this user as their owner.
From your error message, it sounds like your root user is missing or does not have the id 0. This is causing problems when Mahara tries to create the new template page for user portfolio pages.
You can check to see if this is the case by running this query in your database:
SELECT id, username FROM usr WHERE username='root';
You should see something like this:
mahara=# select id, username FROM usr WHERE username='root';
id | username
----+----------
0 | root
(1 row)
If you see a different id, or no results, then you'll need to look at ways to change the root user back to 0. I would suggest just doing an UPDATE query on the usr table, but there actually should be some other existing pages as well that are owned by the root user, and if that user for some reason has a non-zero ID then you'll need to update those other views to the correct (zero) ID, and possibly update some other places in the database as well.
Cheers,
Aaron
23 November 2015, 18:59
Thank Aaron. That was just the info I need to fix my problem. I'm back in business.
24 November 2015, 11:54
Good to hear!
Out of curiosity, what did you wind up doing to fix it?
And do you have any idea how you wound up missing the root user at id 0? This happens from time to time and we haven't been able to figure out what causes it. My best guess is it might be a result of backing up and restoring the database from a SQL dump.
Cheers,
Aaron
24 November 2015, 15:37
Hi Aaron. Again, thanks for your help. After posting my request for assistance I went out and had a beer and listened to some great blues music and when I got back, your answer was waiting for me. I may have to build beer and Blues music into my troubleshooting routine on a regular basis!
Re the fix I reviewed the usr table database at your suggestion and found that user "root" was now listed with ID 14 and that there was no user with id 0 or 1. I then browsed other related tables for pages owned by user ID 14, and didn't find any of note. A set of default pages were still set to owner 0 if I recall correctly. I reset the root user to ID "0" and the update completed as expected.
And yes, I did have to reimport the database at one stage after a botched upgrade attempt, so that probably is the moment where things went wrong.
Cheers,
Bill