course_search.install

  1. 7.x modules/course_search/course_search.install
  2. 6.x modules/course_search/course_search.install
  3. 4.x modules/course_search/course_search.install
  4. 5.x modules/course_search/course_search.install

File

modules/course_search/course_search.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install
  4. */
  5. function course_search_install() {
  6. if (!db_table_exists("course_rotation_schedule")) {
  7. $query = "
  8. CREATE TABLE `course_rotation_schedule` (
  9. `id` int(11) NOT NULL AUTO_INCREMENT,
  10. `faculty_id` varchar(30) NOT NULL DEFAULT '',
  11. `course_id` int(11) NOT NULL DEFAULT 0,
  12. `term_id` varchar(20) NOT NULL DEFAULT '',
  13. `entry_value` varchar(20) NOT NULL DEFAULT '',
  14. `posted` int(10) unsigned NOT NULL DEFAULT 0,
  15. `capacity` int(11) DEFAULT NULL,
  16. PRIMARY KEY (`id`),
  17. KEY `capacity` (`capacity`),
  18. KEY `course_id` (`course_id`),
  19. KEY `term_id` (`term_id`),
  20. KEY `posted` (`posted`)
  21. ); ";
  22. db_query($query);
  23. }
  24. if (!db_table_exists("course_syllabi")) {
  25. $query = "
  26. CREATE TABLE `course_syllabi` (
  27. `id` int(11) NOT NULL AUTO_INCREMENT,
  28. `course_id` int(11) NOT NULL DEFAULT 0,
  29. `course_perm_id` varchar(20) NOT NULL DEFAULT '',
  30. `filename` varchar(255) NOT NULL DEFAULT '',
  31. `posted` int(10) unsigned NOT NULL DEFAULT 0,
  32. PRIMARY KEY (`id`),
  33. KEY `course_id` (`course_id`),
  34. KEY `perm` (`course_perm_id`)
  35. ); ";
  36. db_query($query);
  37. }
  38. } // hook_install
  39. /**
  40. * Implements hook_update
  41. */
  42. function course_search_update($old_schema, $new_schema) {
  43. if ($old_schema < 2) {
  44. // Add new column to course_rotation_schedule to keep up with seat capacity.
  45. db_query("ALTER TABLE course_rotation_schedule ADD COLUMN `capacity` int(11) ");
  46. db_query("ALTER TABLE course_rotation_schedule ADD INDEX (`capacity`) ");
  47. // Also add extra indexes for better searching
  48. db_query("ALTER TABLE course_rotation_schedule ADD INDEX (`course_id`) ");
  49. db_query("ALTER TABLE course_rotation_schedule ADD INDEX (`term_id`) ");
  50. db_query("ALTER TABLE course_rotation_schedule ADD INDEX (`posted`) ");
  51. }
  52. } // hook_update

Functions

Namesort descending Description
course_search_install Implementation of hook_install
course_search_update Implements hook_update