Issue Details (XML | Word | Printable)

Key: MDL-12023
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Francois Marier
Reporter: Francois Marier
Votes: 1
Watchers: 3
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Fixes for upgrade issues (from 1.6 to 1.8 on Postgres 8.1)

Created: 05/Nov/07 01:48 PM   Updated: 03/Jan/08 08:03 PM
Return to search
Component/s: Database SQL/XMLDB
Affects Version/s: 1.8.4, 1.9
Fix Version/s: 1.6.6, 1.7.4, 1.8.4, 1.9, 2.0

File Attachments: 1. HTML File 16_to_18_upgrade_log.html (711 kB)
2. Text File 16_to_18_upgrade_on_postgres_16STABLE.patch (0.0 kB)
3. Text File 16_to_18_upgrade_on_postgres_16STABLE.patch (1 kB)
4. Text File 16_to_18_upgrade_on_postgres_17STABLE.patch (0.4 kB)
5. Text File 16_to_18_upgrade_on_postgres_17STABLE.patch (2 kB)
6. Text File 16_to_18_upgrade_on_postgres_18STABLE.patch (0.4 kB)
7. Text File 16_to_18_upgrade_on_postgres_18STABLE.patch (2 kB)
8. Text File 16_to_18_upgrade_on_postgres_19STABLE.patch (0.4 kB)
9. Text File 16_to_18_upgrade_on_postgres_19STABLE.patch (2 kB)
10. Text File 16_to_18_upgrade_on_postgres_CVSHEAD.patch (0.4 kB)
11. Text File 16_to_18_upgrade_on_postgres_CVSHEAD.patch (2 kB)
12. Text File mod-exercise_add_late_field_16STABLE.patch (2 kB)
13. Text File mod-exercise_add_late_field_17STABLE.patch (2 kB)
14. Text File mod-exercise_add_late_field_18STABLE.patch (2 kB)
15. Text File mod-exercise_add_late_field_18STABLE.patch (2 kB)
16. Text File mod-exercise_add_late_field_19STABLE.patch (2 kB)
17. Text File mod-exercise_add_late_field_19STABLE.patch (2 kB)
18. Text File mod-exercise_add_late_field_19STABLE.patch (2 kB)
19. Text File mod-exercise_add_late_field_CVSHEAD.patch (2 kB)
20. Text File mod-exercise_add_late_field_CVSHEAD.patch (2 kB)
21. Text File mod-scorm_version_field_16STABLE.patch (0.5 kB)
22. Text File mod-scorm_version_field_16STABLE.patch (0.5 kB)
23. Text File mod-scorm_version_field_18STABLE.patch (1 kB)
24. Text File mod-scorm_version_field_19STABLE.patch (1 kB)
25. Text File mod-scorm_version_field_19STABLE.patch (1 kB)
26. Text File mod-scorm_version_field_CVSHEAD.patch (1 kB)
27. Text File mod-scorm_version_field_CVSHEAD.patch (1 kB)
28. Text File question-type-rqp_missing_servers_table_16STABLE.patch (2 kB)
29. Text File question-type-rqp_missing_servers_table_17STABLE.patch (2 kB)
30. Text File question-type-rqp_missing_servers_table_18STABLE.patch (2 kB)

Environment: Linux 2.6.22, Ubuntu 7.10, Postgres 8.1

Database: PostgreSQL
Participants: Eloy Lafuente (stronk7), Francois Marier, Martin Dougiamas and Petr Skoda
Security Level: None
Resolved date: 14/Nov/07
Affected Branches: MOODLE_18_STABLE, MOODLE_19_STABLE
Fixed Branches: MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE


 Description  « Hide
While doing an upgrade from 1.6.? to MOODLE_18_STABLE for a client, I had to remove a few calls to rebuild_course_cache() which were interfering with the upgrade process:

  - 16_to_18_upgrade_on_postgres.patch

Then, I compared the database schemas of a fresh MOODLE_18_STABLE install with the upgraded database and fixed the following discrepancies:

  - mod-exercise_add_late_field.patch: add the 'late' field which was missing from exercise_submissions
  - mod-scorm_version_field.patch: add the 'version' field which was missing from scorm
  - question-type-rqp_missing_servers_table.patch: adds the missing 'question_rqp_servers' table

These patches are against:

  - MOODLE_18_STABLE
  - MOODLE_19_STABLE
  - CVSHEAD

except for the rqp question type one since it's no longer part of the core. I have committed a fix for that one in contrib HEAD.

After making these changes, I was able to upgrade this install of Moodle 1.6 to 1.8 without any errors or differences in the schema.

Francois

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Francois Marier added a comment - 05/Nov/07 01:52 PM
This should probably not be tagged as "Major". Sorry about that.

Francois Marier added a comment - 06/Nov/07 04:25 PM
To answer your question from Skype:

> Eloy Lafuente: Does Postgres support "backticks" ? Just saw some in the very first lines of
> mod/exercise/lib/postgres.php when reviewing http://tracker.moodle.org/browse/MDL-12023

I've run the following test on Postgres 8.1:

<?php
require_once('config.php');
require_login();
execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD `late` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'");
print "\nLast DB error: ".$db->ErrorMsg()."\n";
?>

and got:

Last DB error: ERROR: syntax error at or near "`" LINE 1: ALTER TABLE `mdl_exercise_submissions` ADD `late` TINYINT(3)... ^

Which is likely the reason it had been removed from the branch I am using here at Catalyst.


Francois Marier added a comment - 07/Nov/07 01:46 PM
New versions of these patches which keep the module versions in sync between 1.9 and HEAD

Eloy Lafuente (stronk7) added a comment - 09/Nov/07 04:21 AM
Oki. About patches 1-5 some questions:

1) Why do you take out some rebuild_course_cache() calls? Is that really necessary (I can see the point about not having too much sense to execute them repeatedly if such data isn't needed by the upgrade script itself). Have you left at least one call enabled?

2) In the 18STABLE version.... there is one "extra" change about one create table statement. Why? If has sense, shouldn't it be in all versions?

Will review the next, in some hours... thanks!


Francois Marier added a comment - 09/Nov/07 05:19 AM
Thanks for reviewing these ones Eloy, I wasn't sure exactly about the two things that you pointed out and was hoping to discuss them a bit here

I made these changes in order to be able to go through the upgrade successfully. I don't remember exactly what the errors were but I think it had something to do with role assignments being done without the role tables being there yet.

I will do another test upgrade to see if I can get the exact error message for you.


Francois Marier added a comment - 09/Nov/07 05:22 AM
By the way, I'll commit the postgres DB fixes to exercise, scorm and rqp today once Penny has reviewed them.

Francois Marier added a comment - 09/Nov/07 07:12 AM
Updated patch for mod/scorm on 1.6.

Note that on 1.6 and 1.7, the postgres upgrade script is fine.


Eloy Lafuente (stronk7) added a comment - 09/Nov/07 08:06 AM
Great no problem at all!

Just be careful with version files (I think it's easy to move the versions to the same value because there weren't more changes between them). I've quick-reviewed the DB changes (attachments nº6 and so on) and look correct.

Just have some doubts about the 2 points exposed above (the need to keep at least ONE rebuild_course_cache() call and the create table change).

Anyway, I assign this bug to you... (I'll remain as watcher).

Happy commits with Penny (and don't forget tagging!)

Great work, thanks! Ciao


Francois Marier added a comment - 09/Nov/07 08:30 AM
Get rid of backticks in the Postgres upgrade file

Francois Marier added a comment - 09/Nov/07 09:50 AM
All patches except 1-5 were committed with Penny.

Francois Marier added a comment - 09/Nov/07 01:07 PM
Alright, after doing more tests on this Postgres upgrade from 1.6 to 1.8, it turns out that the only necessary change in those 16_to_18_upgrade patches is the removal of "rebuild_course_cache()" in lib/db/upgrade.php.

How should we fix this?


Petr Skoda added a comment - 13/Nov/07 05:57 AM
Adding Tim, ML says it is the bug related to quiz commit you asked about today...

Martin Dougiamas added a comment - 14/Nov/07 10:54 AM
No no no no no Francois you can't make database changes in the stable branches!

http://moodle.cvs.sourceforge.net/moodle/moodle/mod/scorm/db/upgrade.php

Have you done this anywhere else?


Martin Dougiamas added a comment - 14/Nov/07 11:13 AM
My apologies, I over reacted there. Generally you should not, but I agree that in this case it is OK and works fine.

Francois Marier added a comment - 14/Nov/07 12:21 PM
The rebuild_course_cache() errors have been moved to MDL-12160