This is a database change script to update from 1.1 to HEAD, This will solve a lot of issues that existed. This will also migrate your data to the new database scheme.

Thank you BenjaminW for your help on this.

Comments

westwesterson’s picture

Priority: Critical » Normal
Status: Needs work » Needs review
StatusFileSize
new13.24 KB

I actually had a chance to look this over again, and i haven't tested this yet, but i think you need to add additional { } around the database names in certain areas. This allows for users with a database prefix to use the tables without hacking the update file. I have provided a patch which should fix for this. For example:
$old_value = db_fetch_object(db_query("SELECT name,id FROM {sequences} WHERE name='%s'",'quiz_question_answer_aid'));
should be
$old_value = db_fetch_object(db_query("SELECT name,id FROM {sequences} WHERE name='%s'",'{quiz_question_answer}_aid'));
instead.

*Note this thread was originally at http://drupal.org/node/175568 but has been moved to this one, as it has more current information.

westwesterson’s picture

Additionally, we should figure out if pgsql is going into this next release, and if that is the case either we need to make sure that grab_old_quiz_data() is cross compatible with both databases or contained within the mysql switch.

And also we probably want to rename grab old quiz data to something different like quiz_update_schema_1-1_2-0() in case of another schema update later down the road. This also makes sure that it is within the quiz namespace.

westwesterson’s picture

StatusFileSize
new13.38 KB

here i implemented the above changes to the patch. Renamed grab_old_quiz_data() to quiz_data_update_2() and moved the function call inside of mysql switch case. If this is a universal patch please correct this.

I also ran the module through coder and found a few nit-picky coding standards fixes. And fixed a few more documentation errors.

kylebrowning’s picture

I tested this and it is still working.
:)

westwesterson’s picture

Status: Needs review » Fixed

Works beautifully even on complicated installs. Committed after thorough testing. Good Job!

westwesterson’s picture

Status: Fixed » Needs work

I have found a number of errors with the update_N function, despite my above comments. The number of questions after conversions is skewed. I have a quiz with 2 questions, but after the update it thinks there are 4 in the quiz.

The user results also don't show up correctly. I will look into this more, i have again taken this patch out from the head as it is not stable, I consider potentially loosing results unstable. (This may simply be a shift of result ids, but i have to look into this more.)

senpai’s picture

Priority: Normal » Critical

Marking as critical, cause anything that sorta looses data is sorta a bad thing. And stuff.

kylebrowning’s picture

Well, the reason it doubles i believe is b/c we dont delete the old tables maybe?

westwesterson’s picture

this might have something to do with some faulty info from quiz version 1.1. In that version number_of_questions was a mess, and is not a reliable method for counting the number of questions. And this number if i remember correctly applied to the whole module, not just random questions. So basically I think this is a quiz 1.1 flaw, the conversion here seems right, but the way the numbering system worked in 1.1 was really buggy.

kylebrowning’s picture

Is there any sort of way we can handle this programmatically or should we offer a patch to 1.1 with this upgrade script?

westwesterson’s picture

We shouldn't rely on operations which take the number of questions from the previous database, and instead we can extract that information when we de-serialize arrays. We should check into similar functionality for result ids to see whats going on there too.

kscheirer’s picture

sounds like we should generate a new number_of_questions based on the actual number found for that node. To go along with that we should be setting the number of random questions as (old)number_of_questions - #actually found

does that make sense?

westwesterson’s picture

Priority: Normal » Critical
Status: Needs review » Needs work
StatusFileSize
new13.35 KB

heres a modified patch which sets the number of random questions to zero. (Not ideal but works better than messing up every quiz. Though there is still data loss, the data just might not be worth keeping.)

If we are to correct this we probably will need to add another level of recursion. Is an O(n^2) query still something that can be handled on a large site? Is this ok, because it is a one time operation? or should we let users re-do their number of random questions?

westwesterson’s picture

commiting this so it can be tested. We still need to make this compatable with postgresql.

miccil’s picture

StatusFileSize
new11.14 KB

This is my version con pgsql update code.
For db schema update it seems to work,
but for data I don't know because quiz 5x-1.1
is too much buggy for inserting something with pgsql.

westwesterson’s picture

Status: Needs work » Fixed

assuming this works well enough for beta, i'm going to submit this as well

senpai’s picture

Yeah, go head. I mean, this is the only way to get things tested in real-time. Commit it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

  • Commit a854892 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x by westwesterson:
    Upgrade Patch from 5.x-1.1 to HEAD Issue #198943 by ocyrus, BenjaminW...
  • Commit 5968a90 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x by westwesterson:
    #198943 update_N by ocyrus, BenjaminW and westwesterson
    
    
  • Commit 0ed70a9 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x by westwesterson:
    #198943 update_N for pgsql by miccil
    
    

  • Commit a854892 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages by westwesterson:
    Upgrade Patch from 5.x-1.1 to HEAD Issue #198943 by ocyrus, BenjaminW...
  • Commit 5968a90 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages by westwesterson:
    #198943 update_N by ocyrus, BenjaminW and westwesterson
    
    
  • Commit 0ed70a9 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages by westwesterson:
    #198943 update_N for pgsql by miccil
    
    

  • Commit a854892 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages, 2269219 by westwesterson:
    Upgrade Patch from 5.x-1.1 to HEAD Issue #198943 by ocyrus, BenjaminW...
  • Commit 5968a90 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages, 2269219 by westwesterson:
    #198943 update_N by ocyrus, BenjaminW and westwesterson
    
    
  • Commit 0ed70a9 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages, 2269219 by westwesterson:
    #198943 update_N for pgsql by miccil
    
    

  • Commit a854892 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, 2269219 by westwesterson:
    Upgrade Patch from 5.x-1.1 to HEAD Issue #198943 by ocyrus, BenjaminW...
  • Commit 5968a90 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, 2269219 by westwesterson:
    #198943 update_N by ocyrus, BenjaminW and westwesterson
    
    
  • Commit 0ed70a9 on 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, 2269219 by westwesterson:
    #198943 update_N for pgsql by miccil