Changes throughout Moodle to remove any reserved words from the

Moodle tables.

ie user -> userid in many tables, plus in user_students
   start -> starttime and end -> endtime

I've just done all this as carefully as I could ... I don't think
I missed anything but it's pretty intensive work and I'd be fooling myself
if I didn't think I'd missed a couple.

Note that this version should pretty much be able to bootstrap itself
using PostgreSQL now ... but this is untested
This commit is contained in:
moodler 2002-12-23 09:39:26 +00:00
parent 1f48942e7d
commit ebc3bd2b24
68 changed files with 277 additions and 461 deletions

View file

@ -50,6 +50,12 @@ function forum_upgrade($oldversion) {
execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` ");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `forum_posts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `forum_ratings` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `forum_subscriptions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -41,7 +41,7 @@ CREATE TABLE prefix_forum_posts (
id int(10) unsigned NOT NULL auto_increment,
discussion int(10) unsigned NOT NULL default '0',
parent int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
created int(10) unsigned NOT NULL default '0',
modified int(10) unsigned NOT NULL default '0',
mailed tinyint(1) unsigned NOT NULL default '0',
@ -60,7 +60,7 @@ CREATE TABLE prefix_forum_posts (
CREATE TABLE prefix_forum_ratings (
id int(10) unsigned NOT NULL auto_increment,
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
post int(10) unsigned NOT NULL default '0',
time int(10) unsigned NOT NULL default '0',
rating tinyint(4) NOT NULL default '0',
@ -74,7 +74,7 @@ CREATE TABLE prefix_forum_ratings (
CREATE TABLE prefix_forum_subscriptions (
id int(10) unsigned NOT NULL auto_increment,
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
forum int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)

View file

@ -4,51 +4,7 @@ function forum_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
if ($oldversion < 2002073008) {
execute_sql("DELETE FROM modules WHERE name = 'discuss' ");
execute_sql("ALTER TABLE `discuss` RENAME `forum_discussions` ");
execute_sql("ALTER TABLE `discuss_posts` RENAME `forum_posts` ");
execute_sql("ALTER TABLE `discuss_ratings` RENAME `forum_ratings` ");
execute_sql("ALTER TABLE `forum` CHANGE `intro` `intro` TEXT NOT NULL ");
execute_sql("ALTER TABLE `forum` ADD `forcesubscribe` INTEGER DEFAULT '0' NOT NULL AFTER `assessed`");
execute_sql("ALTER TABLE `forum` CHANGE `type` `type` ENUM( 'single', 'news', 'social', 'general',
'eachuser', 'teacher' ) DEFAULT 'general' NOT NULL ");
execute_sql("ALTER TABLE `forum_posts` CHANGE `discuss` `discussion` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'add', 'forum', 'name') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'add discussion', 'forum_discussions', 'name') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'add post', 'forum_posts', 'subject') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'update post', 'forum_posts', 'subject') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'view discussion', 'forum_discussions', 'name') ");
execute_sql("DELETE FROM log_display WHERE module = 'discuss' ");
execute_sql("UPDATE log SET action = 'view discussion' WHERE module = 'discuss' AND action = 'view' ");
execute_sql("UPDATE log SET action = 'add discussion' WHERE module = 'discuss' AND action = 'add' ");
execute_sql("UPDATE log SET module = 'forum' WHERE module = 'discuss' ");
notify("Renamed all the old discuss tables (now part of forum) and created new forum_types");
}
if ($oldversion < 2002080100) {
execute_sql("INSERT INTO log_display VALUES ('forum', 'view subscribers', 'forum', 'name') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'update', 'forum', 'name') ");
}
if ($oldversion < 2002082900) {
execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ");
}
if ($oldversion < 2002091000) {
if (! execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ")) {
echo "<P>Don't worry about this error - your server already had this upgrade applied";
}
}
if ($oldversion < 2002100300) {
execute_sql(" ALTER TABLE `forum` CHANGE `open` `open` INTEGER DEFAULT '2' NOT NULL ");
execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 ");
execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 ");
}
if ($oldversion < 2002101001) {
execute_sql(" ALTER TABLE `forum_posts` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `message` ");
}
global $CFG;
return true;

View file

@ -38,7 +38,7 @@ CREATE TABLE forum_posts (
id SERIAL PRIMARY KEY,
discussion integer NOT NULL default '0',
parent integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
created integer NOT NULL default '0',
modified integer NOT NULL default '0',
mailed integer NOT NULL default '0',
@ -56,7 +56,7 @@ CREATE TABLE forum_posts (
CREATE TABLE forum_ratings (
id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
post integer NOT NULL default '0',
time integer NOT NULL default '0',
rating integer NOT NULL default '0'
@ -69,7 +69,7 @@ CREATE TABLE forum_ratings (
CREATE TABLE forum_subscriptions (
id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
forum integer NOT NULL default '0'
);
# --------------------------------------------------------