drachels / moodle-mod_hotquestion

An activity to help teachers collect questions from students in or out of the classroom.
5 stars 15 forks source link

4.0 hotquestion upgrade fails #58

Closed aspark21 closed 1 year ago

aspark21 commented 2 years ago

Moodle: MOODLE_400_STABLE hotquestion: latest master / MOODLE_402_STABLE Upgrading to new version mod_hotquestion DDL sql execution error

More information about this error

×Debug info: Data truncated for column 'tpriority' at row 1 ALTER TABLE mdl_hotquestion_questions MODIFY COLUMN tpriority TINYINT(2) NOT NULL DEFAULT 0 after approved Error code: ddlexecuteerror ×Stack trace: line 492 of /lib/dml/moodle_database.php: ddl_change_structure_exception thrown line 1098 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 77 of /lib/ddl/database_manager.php: call to mysqli_native_moodle_database->change_database_structure() line 597 of /lib/ddl/database_manager.php: call to database_manager->execute_sql_arr() line 609 of /lib/ddl/database_manager.php: call to database_manager->change_field_type() line 553 of /mod/hotquestion/db/upgrade.php: call to database_manager->change_field_precision() line 883 of /lib/upgradelib.php: call to xmldb_hotquestion_upgrade() line 582 of /lib/upgradelib.php: call to upgrade_plugins_modules() line 1935 of /lib/upgradelib.php: call to upgrade_plugins() line 719 of /admin/index.php: call to upgrade_noncore()

drachels commented 2 years ago

I am unable to duplicate this problem. Using the latest Moodle with a freshly installed Hot Question v4.0.1 with some question entered, Moodle detected that there was a newer version of Hot Question available. Then I clicked the button and the upgrade went without a hitch. What method did you use to do the upgrade?

aspark21 commented 2 years ago

upgraded prod data from moodle 3.11

Current version: 2022041000 New Version: 2022051800

aspark21 commented 2 years ago

For reference ran php admin/cli/check_database_schema.php

hotquestion

aspark21 commented 2 years ago

Here's the DDL of the current tables

CREATE TABLE mdl_hotquestion ( id bigint(10) NOT NULL AUTO_INCREMENT, course bigint(10) NOT NULL DEFAULT '0', name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', intro longtext COLLATE utf8mb4_unicode_ci, introformat smallint(4) NOT NULL DEFAULT '0', submitdirections varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Submit your question here', timecreated bigint(10) NOT NULL DEFAULT '0', timemodified bigint(10) NOT NULL DEFAULT '0', timeopen bigint(10) NOT NULL DEFAULT '0', timeclose bigint(10) NOT NULL DEFAULT '0', questionlabel varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Questions', teacherpriorityvisibility tinyint(2) NOT NULL DEFAULT '1', teacherprioritylabel varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Priority', heatvisibility tinyint(2) NOT NULL DEFAULT '1', heatlabel varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Heat', heatlimit tinyint(2) NOT NULL DEFAULT '0', anonymouspost tinyint(2) NOT NULL DEFAULT '1', authorhide tinyint(2) NOT NULL DEFAULT '0', approval tinyint(2) NOT NULL DEFAULT '0', approvallabel varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Approved', removelabel varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Remove', scale bigint(10) NOT NULL DEFAULT '0', assessed bigint(10) NOT NULL DEFAULT '0', assessedtimestart bigint(10) NOT NULL DEFAULT '0', assesstimefinish bigint(10) NOT NULL DEFAULT '0', comments smallint(4) NOT NULL DEFAULT '0', assessedtimefinish bigint(10) NOT NULL DEFAULT '0', assesstimestart bigint(10) NOT NULL DEFAULT '0', grade bigint(10) NOT NULL DEFAULT '0', postmaxgrade tinyint(2) NOT NULL DEFAULT '0', factorheat tinyint(2) DEFAULT '0', factorpriority tinyint(2) NOT NULL DEFAULT '0', factorvote tinyint(2) NOT NULL DEFAULT '0', completionpost tinyint(2) NOT NULL DEFAULT '0', completionvote tinyint(2) NOT NULL DEFAULT '0', completionpass tinyint(2) DEFAULT '0', PRIMARY KEY (id), KEY mdl_hotq_cou_ix (course) ) ENGINE=InnoDB AUTO_INCREMENT=10417 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Default comment for hotquestion, please edit me'

CREATE TABLE mdl_hotquestion_questions ( id bigint(10) NOT NULL AUTO_INCREMENT, hotquestion bigint(10) NOT NULL DEFAULT '0', content longtext COLLATE utf8mb4_unicode_ci NOT NULL, format tinyint(2) NOT NULL DEFAULT '0', userid bigint(10) NOT NULL, time bigint(10) NOT NULL, anonymous tinyint(2) NOT NULL DEFAULT '0', approved tinyint(2) NOT NULL DEFAULT '0', tpriority bigint(10) DEFAULT NULL, PRIMARY KEY (id), KEY mdl_hotqques_tim_ix (time), KEY mdl_hotqques_hot_ix (hotquestion) ) ENGINE=InnoDB AUTO_INCREMENT=51613 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='The questions that students submit.'

aspark21 commented 2 years ago

Seems to be this line https://github.com/drachels/moodle-mod_hotquestion/blob/master/db/upgrade.php#L550

Where field already created by - https://github.com/drachels/moodle-mod_hotquestion/blob/master/db/upgrade.php#L162

aspark21 commented 2 years ago

took the sledgehammer and ran it manually via workbench

ALTER TABLE moodle_40_220419.mdl_hotquestion_questions MODIFY COLUMN tpriority TINYINT(2) NOT NULL DEFAULT 0 after approved;

22634 row(s) affected, 64 warning(s): 1265 Data truncated for column 'tpriority' at row 1 1265 Data truncated for column 'tpriority' at row 2 1265 Data truncated for column 'tpriority' at row 3 1265 Data truncated for column 'tpriority' at row 4 1265 Data truncated for column 'tpriority' at row 5 1265 Data truncated for column 'tpriority' at row 6 1265 Data truncated for column 'tpriority' at row 7 1265 Data truncated for column 'tpriority' at row 8 1265 Data truncated for column 'tpriority' at row 9 1265 Data truncated for column 'tpriority' at row 10 1265 Data truncated for column 'tpriority' at row 11 1265 Data truncated for column 'tpriority' at row 12 1265 Data truncated for column 'tpriority' at row 13 1265 Data truncated for column 'tpriority' at row 14 1265 Data truncated for column 'tpriority' at row 15 1265 Data truncated for column 'tpriority' at row 16 1265 Data truncated for column 'tpriority' at row 17 1265 Data truncated for column 'tpriority' at row 18 1265 Data truncated for column 'tpriority' at row 19 1265 Data truncated for column 'tpriority' at row 20 1265 Data truncated for column 'tpriority' at row 21 1265 Data truncated for column 'tpriority' at row 22 1265 Data truncated for column 'tpriority' at row 23 1265 Data truncated for column 'tpriority' at row 24 1265 Data truncated for column 'tpriority' at row 25 1265 Data truncated for column 'tpriority' at row 26 1265 Data truncated for column 'tpriority' at row 27 1265 Data truncated for column 'tpriority' at row 28 1265 Data truncated for column 'tpriority' at row 29 1265 Data truncated for column 'tpriority' at row 30 1265 Data truncated for column 'tpriority' at row 31 1265 Data truncated for column 'tpriority' at row 32 1265 Data truncated for column 'tpriority' at row 33 1265 Data truncated for column 'tpriority' at row 34 1265 Data truncated for column 'tpriority' at row 35 1265 Data truncated for column 'tpriority' at row 36 1265 Data truncated for column 'tpriority' at row 37 1265 Data truncated for column 'tpriority' at row 38 1265 Data truncated for column 'tpriority' at row 39 1265 Data truncated for column 'tpriority' at row 40 1265 Data truncated for column 'tpriority' at row 41 1265 Data truncated for column 'tpriority' at row 42 1265 Data truncated for column 'tpriority' at row 43 1265 Data truncated for column 'tpriority' at row 44 1265 Data truncated for column 'tpriority' at row 45 1265 Data truncated for column 'tpriority' at row 46 1265 Data truncated for column 'tpriority' at row 47 1265 Data truncated for column 'tpriority' at row 48 1265 Data truncated for column 'tpriority' at row 49 1265 Data truncated for column 'tpriority' at row 50 1265 Data truncated for column 'tpriority' at row 51 1265 Data truncated for column 'tpriority' at row 52 1265 Data truncated for column 'tpriority' at row 53 1265 Data truncated for column 'tpriority' at row 54 1265 Data truncated for column 'tpriority' at row 55 1265 Data truncated for column 'tpriority' at row 56 1265 Data truncated for column 'tpriority' at row 57 1265 Data truncated for column 'tpriority' at row 58 1265 Data truncated for column 'tpriority' at row 59 1265 Data truncated for column 'tpriority' at row 60 1265 Data truncated for column 'tpriority' at row 61 1265 Data truncated for column 'tpriority' at row 62 1265 Data truncated for column 'tpriority' at row 63 1265 Data truncated for column 'tpriority' at row 64 Records: 22634 Duplicates: 0 Warnings: 977

For reference I had a look at the values SELECT DISTINCT tpriority FROMmoodle_311_release_220524.mdl_hotquestion_questions;

INSERT INTO `` (`tpriority`) VALUES (NULL);
INSERT INTO `` (`tpriority`) VALUES (2);
INSERT INTO `` (`tpriority`) VALUES (1);
INSERT INTO `` (`tpriority`) VALUES (0);
INSERT INTO `` (`tpriority`) VALUES (-1);
INSERT INTO `` (`tpriority`) VALUES (3);
INSERT INTO `` (`tpriority`) VALUES (-2);
INSERT INTO `` (`tpriority`) VALUES (4);
INSERT INTO `` (`tpriority`) VALUES (6);
INSERT INTO `` (`tpriority`) VALUES (7);

Looking at that I assume it's because NULL is more than 2 so needs to be dealt with before the table is altered

aspark21 commented 1 year ago

running 3.11 -> 4.1 beta upgrade and this is still an issue.

Any plans to resolve this?

drachels commented 1 year ago

Yes, I plan on trying to resolve this. I hope to have a fix for the upcoming Moodle 4.1 release. I just have had so many other things going on, that I've not gotten to this item yet.

qqtuyen commented 1 year ago

Moode 3.11.13 having the same error with mod_hotquestion v 4.1.5 do we have a fix for 3.11x version ?

drachels commented 1 year ago

Sorry to take so long to try and fix this. I have been sick a whole bunch over the past year or more. In fact, the whole months of February and March this year, I had eye infections so bad, all I could stand to do was sit in a dark room and try to watch a little TV. Anyway, the master branch has code for what will be HotQuestion v4.1.6 that fixes the problem. I will do some more testing tomorrow on some of my other servers to make sure, and will release this new code with Moodle 4.2, as it removes a bunch of deprecated code that needs to be removed for Moodle 4.2.

drachels commented 1 year ago

Fixed in the past couple of versions. Just forgot to close this due recent severe eye problems.