Index: trunk/extensions/EducationProgram/sql/UpdateUserLinks.sql |
— | — | @@ -0,0 +1,18 @@ |
| 2 | +-- MySQL for the Education Program extension. |
| 3 | +-- Licence: GNU GPL v3+ |
| 4 | +-- Author: Jeroen De Dauw < jeroendedauw@gmail.com > |
| 5 | + |
| 6 | +DROP TABLE IF EXISTS /*_*/ep_cas_per_course; |
| 7 | +DROP TABLE IF EXISTS /*_*/ep_oas_per_course; |
| 8 | +DROP TABLE IF EXISTS /*_*/ep_students_per_course; |
| 9 | + |
| 10 | +-- Links the students with their courses. |
| 11 | +CREATE TABLE IF NOT EXISTS /*_*/ep_users_per_course ( |
| 12 | + upc_user_id INT unsigned NOT NULL, -- Foreign key on ep_user.user_id |
| 13 | + upc_course_id INT unsigned NOT NULL, -- Foreign key on ep_courses.course_id |
| 14 | + upc_role TINYINT unsigned NOT NULL -- The role the user has for the course |
| 15 | +) /*$wgDBTableOptions*/; |
| 16 | + |
| 17 | +CREATE UNIQUE INDEX /*i*/ep_users_per_course ON /*_*/ep_users_per_course (upc_user_id, upc_course_id, upc_role); |
| 18 | +CREATE INDEX /*i*/ep_upc_course_id ON /*_*/ep_users_per_course (upc_course_id); |
| 19 | +CREATE INDEX /*i*/ep_upc_role ON /*_*/ep_users_per_course (upc_role); |
\ No newline at end of file |
Property changes on: trunk/extensions/EducationProgram/sql/UpdateUserLinks.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 20 | + native |
Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql |
— | — | @@ -104,12 +104,15 @@ |
105 | 105 | |
106 | 106 | |
107 | 107 | -- Links the students with their courses. |
108 | | -CREATE TABLE IF NOT EXISTS /*_*/ep_students_per_course ( |
109 | | - spc_student_id INT unsigned NOT NULL, -- Foreign key on ep_students.student_id |
110 | | - spc_course_id INT unsigned NOT NULL -- Foreign key on ep_courses.course_id |
| 108 | +CREATE TABLE IF NOT EXISTS /*_*/ep_users_per_course ( |
| 109 | + upc_user_id INT unsigned NOT NULL, -- Foreign key on ep_user.user_id |
| 110 | + upc_course_id INT unsigned NOT NULL, -- Foreign key on ep_courses.course_id |
| 111 | + upc_role TINYINT unsigned NOT NULL -- The role the user has for the course |
111 | 112 | ) /*$wgDBTableOptions*/; |
112 | 113 | |
113 | | -CREATE UNIQUE INDEX /*i*/ep_students_per_course ON /*_*/ep_students_per_course (spc_student_id, spc_course_id); |
| 114 | +CREATE UNIQUE INDEX /*i*/ep_users_per_course ON /*_*/ep_users_per_course (upc_user_id, upc_course_id, upc_role); |
| 115 | +CREATE INDEX /*i*/ep_upc_course_id ON /*_*/ep_users_per_course (upc_course_id); |
| 116 | +CREATE INDEX /*i*/ep_upc_role ON /*_*/ep_users_per_course (upc_role); |
114 | 117 | |
115 | 118 | |
116 | 119 | |
— | — | @@ -136,17 +139,6 @@ |
137 | 140 | |
138 | 141 | |
139 | 142 | |
140 | | -CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_course ( |
141 | | - cpc_user_id INT unsigned NOT NULL, -- Foreign key on user.user_id |
142 | | - cpc_course_id INT unsigned NOT NULL -- Foreign key on ep_course.course_id |
143 | | -) /*$wgDBTableOptions*/; |
144 | | - |
145 | | -CREATE UNIQUE INDEX /*i*/ep_cas_per_course ON /*_*/ep_cas_per_course (cpc_user_id, cpc_course_id); |
146 | | - |
147 | | - |
148 | | - |
149 | 143 | -- Online ambassadors. In essence this is an extension to the user table. |
150 | 144 | CREATE TABLE IF NOT EXISTS /*_*/ep_oas ( |
151 | 145 | oa_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
— | — | @@ -160,17 +152,6 @@ |
161 | 153 | |
162 | 154 | |
163 | 155 | |
164 | | -CREATE TABLE IF NOT EXISTS /*_*/ep_oas_per_course ( |
165 | | - opc_user_id INT unsigned NOT NULL, -- Foreign key on user.user_id |
166 | | - opc_course_id INT unsigned NOT NULL -- Foreign key on ep_course.course_id |
167 | | -) /*$wgDBTableOptions*/; |
168 | | - |
169 | | -CREATE UNIQUE INDEX /*i*/ep_oas_per_course ON /*_*/ep_oas_per_course (opc_user_id, opc_course_id); |
170 | | - |
171 | | - |
172 | | - |
173 | 156 | -- Revision table, holding blobs of various types of objects, such as orgs or students. |
174 | 157 | -- This is somewhat based on the (core) revision table and is meant to serve |
175 | 158 | -- as a prototype for a more general system to store this kind of data in a visioned fashion. |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -51,6 +51,13 @@ |
52 | 52 | dirname( __FILE__ ) . '/sql/AddRevIdentifier.sql', |
53 | 53 | true |
54 | 54 | ) ); |
| 55 | + |
| 56 | + $updater->addExtensionUpdate( array( |
| 57 | + 'addTable', |
| 58 | + 'ep_users_per_course', |
| 59 | + dirname( __FILE__ ) . '/sql/UpdateUserLinks.sql', |
| 60 | + true |
| 61 | + ) ); |
55 | 62 | |
56 | 63 | return true; |
57 | 64 | } |