View | Details | Raw Unified | Return to bug 35972
Collapse All | Expand All

(-)a/Koha/Schema/Result/Course.pm (+11 lines)
Lines 31-36 __PACKAGE__->table("courses"); Link Here
31
31
32
unique id for the course
32
unique id for the course
33
33
34
=head2 course_type
35
36
  data_type: 'varchar'
37
  default_value: 'COURSE'
38
  is_nullable: 1
39
  size: 80
40
41
the authorised value for CR_TYPE - determines display context (course reserve, research table, on display, etc.)
42
34
=head2 department
43
=head2 department
35
44
36
  data_type: 'varchar'
45
  data_type: 'varchar'
Lines 114-119 determines whether the course is active Link Here
114
__PACKAGE__->add_columns(
123
__PACKAGE__->add_columns(
115
  "course_id",
124
  "course_id",
116
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
125
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
126
  "course_type",
127
  { data_type => "varchar", default_value => "COURSE", is_nullable => 1, size => 80 },
117
  "department",
128
  "department",
118
  { data_type => "varchar", is_nullable => 1, size => 80 },
129
  { data_type => "varchar", is_nullable => 1, size => 80 },
119
  "course_number",
130
  "course_number",
(-)a/installer/data/mysql/atomicupdate/bug_35972.pl (+70 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "35972",
6
    description => "Add course_type column to courses table for flexible course displays",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        unless ( column_exists( 'courses', 'course_type' ) ) {
12
            say_info( $out, "Adding course_type column to courses table..." );
13
14
            # Add the course_type column with default value 'COURSE'
15
            $dbh->do(
16
                q{
17
                ALTER TABLE courses
18
                ADD COLUMN course_type VARCHAR(80) DEFAULT 'COURSE'
19
                AFTER course_id
20
            }
21
            );
22
23
            say_success( $out, "Added column 'courses.course_type'" );
24
25
            # Migrate existing 'thesis tables' (department='TT') to new system
26
            my $migrated_courses = $dbh->do(
27
                q{
28
                UPDATE courses
29
                SET course_type = 'RESEARCH_TABLE'
30
                WHERE department = 'TT'
31
            }
32
            );
33
34
            if ( $migrated_courses && $migrated_courses > 0 ) {
35
                say_success( $out, "Migrated $migrated_courses thesis table(s) to course_type='RESEARCH_TABLE'" );
36
            } else {
37
                say_info( $out, "No thesis tables (department='TT') found to migrate" );
38
            }
39
40
            # Add authorized value category for course types
41
            $dbh->do(
42
                q{
43
                INSERT IGNORE INTO authorised_value_categories (category_name, is_system)
44
                VALUES ('CR_TYPE', 1)
45
            }
46
            );
47
            say_success( $out, "Added authorized value category 'CR_TYPE'" );
48
49
            # Add default authorized values for course types
50
            $dbh->do(
51
                q{
52
                INSERT IGNORE INTO authorised_values (category, authorised_value, lib, lib_opac)
53
                VALUES
54
                    ('CR_TYPE', 'COURSE', 'Course reserve', 'Course reserve'),
55
                    ('CR_TYPE', 'RESEARCH_TABLE', 'Research table', 'Research table'),
56
                    ('CR_TYPE', 'ON_DISPLAY', 'On display', 'On display')
57
            }
58
            );
59
            say_success( $out, "Added default course type authorized values" );
60
61
            say_info( $out, "Course types can be customized in Administration > Authorized values > CR_TYPE" );
62
            say_info( $out, "The 'lib' field controls staff interface display text" );
63
            say_info( $out, "The 'lib_opac' field controls OPAC display text" );
64
            say_success( $out, "Migration complete: Course reserves now supports multiple display types" );
65
66
        } else {
67
            say_info( $out, "The course_type column already exists in the courses table." );
68
        }
69
    },
70
};
(-)a/installer/data/mysql/en/mandatory/auth_values.yml (+15 lines)
Lines 5739-5741 tables: Link Here
5739
          authorised_value: "770"
5739
          authorised_value: "770"
5740
          lib: "Writer of accompanying material"
5740
          lib: "Writer of accompanying material"
5741
          lib_opac: "Writer of accompanying material"
5741
          lib_opac: "Writer of accompanying material"
5742
5743
        - category: "CR_TYPE"
5744
          authorised_value: "COURSE"
5745
          lib: "Course reserve"
5746
          lib_opac: "Course reserve"
5747
5748
        - category: "CR_TYPE"
5749
          authorised_value: "RESEARCH_TABLE"
5750
          lib: "Research table"
5751
          lib_opac: "Research table"
5752
5753
        - category: "CR_TYPE"
5754
          authorised_value: "ON_DISPLAY"
5755
          lib: "On display"
5756
          lib_opac: "On display"
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 2311-2316 DROP TABLE IF EXISTS `courses`; Link Here
2311
/*!40101 SET character_set_client = utf8mb4 */;
2311
/*!40101 SET character_set_client = utf8mb4 */;
2312
CREATE TABLE `courses` (
2312
CREATE TABLE `courses` (
2313
  `course_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the course',
2313
  `course_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the course',
2314
  `course_type` varchar(80) DEFAULT 'COURSE' COMMENT 'the authorised value for CR_TYPE - determines display context (course reserve, research table, on display, etc.)',
2314
  `department` varchar(80) DEFAULT NULL COMMENT 'the authorised value for the DEPARTMENT',
2315
  `department` varchar(80) DEFAULT NULL COMMENT 'the authorised value for the DEPARTMENT',
2315
  `course_number` varchar(255) DEFAULT NULL COMMENT 'the ''course number'' assigned to a course',
2316
  `course_number` varchar(255) DEFAULT NULL COMMENT 'the ''course number'' assigned to a course',
2316
  `section` varchar(255) DEFAULT NULL COMMENT 'the ''section'' of a course',
2317
  `section` varchar(255) DEFAULT NULL COMMENT 'the ''section'' of a course',
2317
- 

Return to bug 35972