MDL-19315 Renaming published_courses table to course_published (Coding guidlines!!)

This commit is contained in:
Martin Dougiamas
2010-05-16 16:06:15 +00:00
parent 82b90a59c1
commit 0fa096bbca
4 changed files with 31 additions and 36 deletions
+6 -6
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20100513" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20100516" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@@ -2594,7 +2594,7 @@
<INDEX NAME="backupid_parentitemid_ix" UNIQUE="false" FIELDS="backupid, itemname, parentitemid"/>
</INDEXES>
</TABLE>
<TABLE NAME="backup_logs" COMMENT="To store all the logs from backup and restore operations (by db logger)" PREVIOUS="backup_ids_template" NEXT="published_courses">
<TABLE NAME="backup_logs" COMMENT="To store all the logs from backup and restore operations (by db logger)" PREVIOUS="backup_ids_template" NEXT="course_published">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="backupid"/>
<FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="backupid the log record belongs to" PREVIOUS="id" NEXT="loglevel"/>
@@ -2610,13 +2610,13 @@
<INDEX NAME="backupid-id" UNIQUE="true" FIELDS="backupid, id" COMMENT="for quick ordered retrieval by backupid"/>
</INDEXES>
</TABLE>
<TABLE NAME="published_courses" COMMENT="All course that has been published on a hub and the type of publishing (enrol/download)" PREVIOUS="backup_logs">
<TABLE NAME="course_published" COMMENT="Information about how and when an local courses were published to hubs" PREVIOUS="backup_logs">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="hubid"/>
<FIELD NAME="hubid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the id of the &quot;registered on&quot; hub" PREVIOUS="id" NEXT="courseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the id of the published course" PREVIOUS="hubid" NEXT="time"/>
<FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the time when the publication occured" PREVIOUS="courseid" NEXT="enrollable"/>
<FIELD NAME="enrollable" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="1 = enrollable, 0 = downloadable" PREVIOUS="time" NEXT="hubcourseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the id of the published course" PREVIOUS="hubid" NEXT="timepublished"/>
<FIELD NAME="timepublished" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The time when the publication occurred" PREVIOUS="courseid" NEXT="enrollable"/>
<FIELD NAME="enrollable" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="1 = enrollable, 0 = downloadable" PREVIOUS="timepublished" NEXT="hubcourseid"/>
<FIELD NAME="hubcourseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the course id on the hub server" PREVIOUS="enrollable"/>
</FIELDS>
<KEYS>
+17 -22
View File
@@ -4007,6 +4007,8 @@ AND EXISTS (SELECT 'x'
/// Main savepoint reached
upgrade_main_savepoint($result, 2010050403);
}
// fix repository_alfresco version number
if ($result && $oldversion < 2010050411) {
// force to change repository_alfresco version number to upgrade smoothly (from preview 1 -> preview 2)
@@ -4017,43 +4019,36 @@ AND EXISTS (SELECT 'x'
upgrade_main_savepoint($result, 2010050411);
}
if ($result && $oldversion < 2010050413) {
/// Define table published_courses to be created
if ($result && $oldversion < 2010051500) {
/// Fix a bad table name that existed for a few days in HEAD
$table = new xmldb_table('published_courses');
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
/// Adding fields to table published_courses
/// Define table course_published to be created
$table = new xmldb_table('course_published');
/// Adding fields to table course_published
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('hubid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timepublished', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('enrollable', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
$table->add_field('hubcourseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table published_courses
/// Adding keys to table course_published
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Conditionally launch create table for published_courses
/// Conditionally launch create table for course_published
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Main savepoint reached
upgrade_main_savepoint($result, 2010050413);
}
if ($result && $oldversion < 2010050414) {
/// Define field hubcourseid to be added to published_courses
$table = new xmldb_table('published_courses');
$field = new xmldb_field('hubcourseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'enrollable');
/// Conditionally launch add field hubcourseid
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
/// Main savepoint reached
upgrade_main_savepoint($result, 2010050414);
upgrade_main_savepoint($result, 2010051500);
}
+7 -7
View File
@@ -197,28 +197,28 @@ class hub {
$publication->courseid = $courseid;
$publication->hubcourseid = $hubcourseid;
$publication->enrollable = $enrollable;
$publication->time = time();
$DB->insert_record('published_courses', $publication);
$publication->timepublished = time();
$DB->insert_record('course_published', $publication);
}
public function update_enrollable_course_publication($publicationid) {
global $DB;
$publication = new stdClass();
$publication->id = $publicationid;
$publication->time = time();
$DB->update_record('published_courses', $publication);
$publication->timepublished = time();
$DB->update_record('course_published', $publication);
}
public function get_publications($hubid, $courseid, $enrollable) {
global $DB;
return $DB->get_records('published_courses',
return $DB->get_records('course_published',
array('hubid' => $hubid, 'courseid' => $courseid, 'enrollable' => $enrollable));
}
public function get_publication($hubcourseid) {
global $DB;
return $DB->get_record('published_courses',
return $DB->get_record('course_published',
array('hubcourseid' => $hubcourseid));
}
@@ -347,4 +347,4 @@ class hub {
return $hubs;
}
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2010050414; // YYYYMMDD = date of the last version bump
$version = 2010051500; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 Preview 1 (Build: 20100516)'; // Human-friendly version name