Upgrading to v.3.0.9 - Revisited

Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -
Number of replies: 8

Hello again,

I've previously managed to upgrade to v.3.0.9 but my moodledata folder (from v.2.5.6) was left out of this and I used a new moodledata folder instead created during this installation. I did require upgrading to v.2.7.19 in-between and that enabled the upgrade to proceed to v.3.0.9.

Now I've gone back to the test server and restored the v.2.5.6 database and moodle and I'm trying to redo everything and upgrade my database and moodledata to v.3.0.9. However, when I'm presently trying to reinstall v.2.7.19 again and I am getting an "Error Writing to Database" error message that I did not get the first time.

Can someone please explain why this is happening and what I can do to proceed with this upgrade?

Thank you again.

Average of ratings: -
In reply to Roman Cylwa

Re: Upgrading to v.3.0.9 - Revisited

by Bret Miller -
Picture of Particularly helpful Moodlers

Some Moodle versions add tables to the database and if those tables already exist, you'll get an error. So when you restore your 2.5.6 database, make sure the database you're restoring into is empty first. I found a nice command line statement to do that which you're welcome to try, or you can simply select all the tables in phpMyAdmin and drop them.

mysqldump --add-drop-table -h$sqlhost -u$sqluser -p$sqlpass --no-data $todb  | grep ^DROP | mysql -h$sqlhost -u$sqluser -p$sqlpass $todb

In reply to Bret Miller

Re: Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -

Thank you for the response.

Is there a version of this command that will work for MS SQL?

In reply to Bret Miller

Re: Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -

One other thing.

I've dropped the tables in the DB and then imported the tables from the v.2.5.6 backup so there wouldn't be any remaining tables from later versions.

In reply to Roman Cylwa

Re: Upgrading to v.3.0.9 - Revisited

by Bret Miller -
Picture of Particularly helpful Moodlers

Well, that's what I was asking. Dropping all the tables before a restore is essential. 

For future reference should someone need to drop all tables in an MSSQL database, try:

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

In reply to Bret Miller

Re: Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -

Hi again,

I've dropped the tables with the command that you provided, imported the database from a backup, and when I went back to reinstall the 'Error Writing to Database' still appears.

In reply to Roman Cylwa

Re: Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -

I've been checking this forum and I've tried the Search and Replace Tool and that will give me the same error message. I can't seem to get past this error message for reinstallation/upgrading.

In reply to Roman Cylwa

Re: Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -

Small update here.

With debugging on it said that the table - mdl_sessions could not accept a value as the id column was set to not accept NULL values. I've altered the table to enable this but now ran into this error:

Coding error detected, it must be fixed by a programmer: moodle_database::update_record_raw() id field must be specified.

Debugging indicates that the sqlsrv_native_moodle_database.php has a coding exception thrown and I can't seem to get around this part.

Thanks.

In reply to Roman Cylwa

Re: Upgrading to v.3.0.9 - Revisited

by Roman Cylwa -

I'm still unable to get around this issue and it continues to stall my upgrade attempts. I'd like to be able to upgrade from 2.5.6 to 2.7.19 to 3.0.9 with the corresponding moodledata and database table schema together so that there will be no further errors.

The moodle_database::update_record_raw() id field must be specified is still problematic and enabling debugging has not provided much further clarity.

Any help is highly appreciated.