From 7a3a4cff546e0dba91ec2dcc20a99032caa71af9 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 17 May 2006 06:34:50 +0000 Subject: [PATCH] moodle16cleanup: mod/lesson drop unused table lesson_essay, set the correct column datatype and default value --- mod/lesson/db/postgres7.php | 32 ++++++++++++++++++++++++++++++++ mod/lesson/db/postgres7.sql | 15 --------------- mod/lesson/version.php | 2 +- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/mod/lesson/db/postgres7.php b/mod/lesson/db/postgres7.php index a5220bed35..4d6c92287f 100644 --- a/mod/lesson/db/postgres7.php +++ b/mod/lesson/db/postgres7.php @@ -312,6 +312,38 @@ function lesson_upgrade($oldversion) { table_column('lesson_default', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'retake'); } + if ($oldversion < 2006050101) { + // drop the unused table + execute_sql('DROP TABLE '.$CFG->prefix.'lesson_essay', false); + + // properly set the correct default values + modify_database('', 'ALTER TABLE prefix_lesson + ALTER COLUMN activitylink TYPE int8, + ALTER COLUMN activitylink SET DEFAULT 0, + ALTER COLUMN dependency TYPE int8, + ALTER COLUMN dependency SET DEFAULT 0'); + + modify_database('', 'ALTER TABLE prefix_lesson_timer + ALTER COLUMN lessontime SET DEFAULT 0, + ALTER COLUMN lessonid SET DEFAULT 0, + ALTER COLUMN userid SET DEFAULT 0, + ALTER COLUMN starttime SET DEFAULT 0'); + + modify_database('', 'ALTER TABLE prefix_lesson_branch + ALTER COLUMN lessonid SET DEFAULT 0, + ALTER COLUMN timeseen SET DEFAULT 0, + ALTER COLUMN userid SET DEFAULT 0, + ALTER COLUMN retry SET DEFAULT 0, + ALTER COLUMN pageid SET DEFAULT 0, + ALTER COLUMN flag SET DEFAULT 0'); + + modify_database('', 'ALTER TABLE prefix_lesson_high_scores + ALTER COLUMN nickname SET DEFAULT \'\', + ALTER COLUMN lessonid SET DEFAULT 0, + ALTER COLUMN gradeid SET DEFAULT 0, + ALTER COLUMN userid SET DEFAULT 0'); + } + return true; } diff --git a/mod/lesson/db/postgres7.sql b/mod/lesson/db/postgres7.sql index 280cb1723c..3b3f9aeede 100644 --- a/mod/lesson/db/postgres7.sql +++ b/mod/lesson/db/postgres7.sql @@ -156,21 +156,6 @@ CREATE TABLE prefix_lesson_branch timeseen INT8 not null default '0' ); -CREATE TABLE prefix_lesson_essay - ( id SERIAL8 PRIMARY KEY, - lessonid INT8 not null default '0', - userid INT8 not null default '0', - pageid INT8 not null default '0', - answerid INT8 not null default '0', - try INT8 not null default '0', - answer text not null default '', - graded INT not null default 0, - score INT8 not null default 0, - response text not null default '', - sent INT not null default 0, - timesubmitted INT8 not null default '0' - ); - CREATE TABLE prefix_lesson_high_scores ( id SERIAL8 PRIMARY KEY, lessonid INT8 not null default '0', diff --git a/mod/lesson/version.php b/mod/lesson/version.php index 7e4101fbcc..69d1323b6d 100644 --- a/mod/lesson/version.php +++ b/mod/lesson/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2006050100; // The current module version (Date: YYYYMMDDXX) +$module->version = 2006050101; // The current module version (Date: YYYYMMDDXX) $module->requires = 2005021600; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) -- 2.39.5