Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.2, 1.9
-
None
-
practically any
-
Any
-
MOODLE_18_STABLE, MOODLE_19_STABLE
-
MOODLE_18_STABLE
Description
Hi,
I was tracing the upgrade process in order to fix one bug in the 1.7 => 1.8 migration under Oracle (MDL-10575) when I've seen some code in the upgrade of groups that, or I'm completely wrong, or is breaking any non-mysql installation:
1) As part of the process, the "groups" table is renamed to "groups_temp", and then records are copied as "raw" inserts (i.e. including explicitly the id in the insert from one table to other).
2) The upgrade process, instead of declaring all the XMLDB tables/fields/indexes, uses directly the install.xml file to perform the creation of the schema.
With those 2 points I think that all these disasters are true:
D1) Sequences are lost. Absolutely. At least under PostgreSQL and Oracle. When one table is renamed (to temp_groups) its sequence is moved together and when the new table (groups) is created it comes with its own sequence initialy set to 1). So, if any record has been deleted from the 1.7 groups table along its life, then the copy of raw registers won't coincide with the number of the sequence in the new table. Problems for sure!
D2) Some databases (MSSQL AFAIK) doesn't allow insertion in fields that are governed by sequences. Broken for sure.
D3) We must think that each block of code in upgrade.php is one photograph of the DB, while the install.xml file changes along the time. So it's 1000% incorrect to use in the upgrade.php something that potentially, has changed!!! FORBIDDEN or posterior steps in the upgrade process can fail completely.
With all these Disasters... I think that the upgrade is broken in near each Oracle, PostgreSQL and MSSQL intallations (with more posibilities depending of the changes performed to the install.xml file along the life on the 1.8 group/db code).
And should be fixed. Completely.
To fix it I would propose to:
1) Apply all the needed modifications to the schema, from the 1.7 version to the 1.8 one, using the upgrade.php file as usual (creating all the needed XMLDB objects and calling ddllib functions - The editor can help here.
2) Once everything has been created. Populate tables as needed. I don't know too much about this.
This new 1 & 2 code should REPLACE the current one. 100%
I've been talking with Petr and HEAD seems to be free of this problems, because the upgrade code has been completely replaced.
Please, I think it's important. Each day one server becomes upgraded... if they were using groups... problems!