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

(-)a/Koha/RecordSource.pm (+14 lines)
Lines 46-51 sub usage_count { Link Here
46
    return $self->_result->biblio_metadatas->count();
46
    return $self->_result->biblio_metadatas->count();
47
}
47
}
48
48
49
=head3 delete
50
51
Overridden delete method to prevent system default deletions
52
53
=cut
54
55
sub delete {
56
    my ($self) = @_;
57
58
    Koha::Exceptions::CannotDeleteDefault->throw if $self->is_system;
59
60
    return $self->SUPER::delete;
61
}
62
49
=head2 Internal methods
63
=head2 Internal methods
50
64
51
=head3 _type
65
=head3 _type
(-)a/api/v1/swagger/definitions/record_source.yaml (+4 lines)
Lines 14-19 properties: Link Here
14
  usage_count:
14
  usage_count:
15
    description: Record source usage count (x-koha-embed)
15
    description: Record source usage count (x-koha-embed)
16
    type: integer
16
    type: integer
17
  is_system:
18
    description: Is this record source system or not
19
    type: boolean
20
    readOnly: true
17
additionalProperties: false
21
additionalProperties: false
18
required:
22
required:
19
  - name
23
  - name
(-)a/installer/data/mysql/atomicupdate/bug_35380.pl (+36 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "35380",
5
    description => "Add new unique name to record sources, add default record sources, add is_system column to default record sources.",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        # change name to be unique
11
        if ( !unique_key_exists('record_sources', 'name') ) {
12
            $dbh->do(q{
13
                ALTER TABLE record_sources
14
                ADD UNIQUE KEY name (`name`)
15
            });
16
            say $out "Added unique key 'name' ";
17
        }
18
        
19
        # add column is system
20
        unless ( column_exists('record_sources', 'is_system') ) {
21
          $dbh->do(q{ ALTER TABLE record_sources ADD COLUMN `is_system` TINYINT(1) NOT NULL DEFAULT 0 AFTER can_be_edited });
22
          say $out "Added column 'record_sources.is_system'";
23
        }
24
25
        $dbh->do(q{
26
            INSERT IGNORE INTO record_sources ( name, can_be_edited, is_system )
27
            VALUES
28
            ('batchmod', 0, 1 ),
29
            ('intranet', 0, 1 ),
30
            ('batchimport', 0, 1 ),
31
            ('z3950', 0, 1 ),
32
            ('bulkmarcimport', 0, 1 ),
33
            ('import_lexile', 0, 1 )
34
        });
35
    },
36
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +3 lines)
Lines 5540-5546 CREATE TABLE `record_sources` ( Link Here
5540
  `record_source_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary key for the `record_sources` table',
5540
  `record_source_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary key for the `record_sources` table',
5541
  `name` text NOT NULL COMMENT 'User defined name for the record source',
5541
  `name` text NOT NULL COMMENT 'User defined name for the record source',
5542
  `can_be_edited` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If records from this source can be edited',
5542
  `can_be_edited` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If records from this source can be edited',
5543
  PRIMARY KEY (`record_source_id`)
5543
  `is_system` tinyint(1) NOT NULL DEFAULT 0,
5544
  PRIMARY KEY (`record_source_id`),
5545
  UNIQUE KEY `name` (`name`(191))
5544
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5546
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5545
/*!40101 SET character_set_client = @saved_cs_client */;
5547
/*!40101 SET character_set_client = @saved_cs_client */;
5546
5548
5547
- 

Return to bug 35380