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

(-)a/Koha/Schema/Result/RecordSource.pm (+112 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::RecordSource;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::RecordSource
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<record_sources>
19
20
=cut
21
22
__PACKAGE__->table("record_sources");
23
24
=head1 ACCESSORS
25
26
=head2 record_source_id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
Primary key for the `record_sources` table
33
34
=head2 name
35
36
  data_type: 'text'
37
  is_nullable: 0
38
39
User defined name for the record source
40
41
=head2 can_be_edited
42
43
  data_type: 'tinyint'
44
  default_value: 0
45
  is_nullable: 0
46
47
If records from this source can be edited
48
49
=cut
50
51
__PACKAGE__->add_columns(
52
  "record_source_id",
53
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
54
  "name",
55
  { data_type => "text", is_nullable => 0 },
56
  "can_be_edited",
57
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
58
);
59
60
=head1 PRIMARY KEY
61
62
=over 4
63
64
=item * L</record_source_id>
65
66
=back
67
68
=cut
69
70
__PACKAGE__->set_primary_key("record_source_id");
71
72
=head1 RELATIONS
73
74
=head2 biblio_metadatas
75
76
Type: has_many
77
78
Related object: L<Koha::Schema::Result::BiblioMetadata>
79
80
=cut
81
82
__PACKAGE__->has_many(
83
  "biblio_metadatas",
84
  "Koha::Schema::Result::BiblioMetadata",
85
  { "foreign.record_source_id" => "self.record_source_id" },
86
  { cascade_copy => 0, cascade_delete => 0 },
87
);
88
89
=head2 deletedbiblio_metadatas
90
91
Type: has_many
92
93
Related object: L<Koha::Schema::Result::DeletedbiblioMetadata>
94
95
=cut
96
97
__PACKAGE__->has_many(
98
  "deletedbiblio_metadatas",
99
  "Koha::Schema::Result::DeletedbiblioMetadata",
100
  { "foreign.record_source_id" => "self.record_source_id" },
101
  { cascade_copy => 0, cascade_delete => 0 },
102
);
103
104
105
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2024-01-24 18:05:50
106
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WX72aRYhWBK9bQWr9AJk2A
107
108
__PACKAGE__->add_columns(
109
    '+can_be_edited' => { is_boolean => 1 },
110
);
111
112
1;
(-)a/installer/data/mysql/atomicupdate/bug_35919.pl (+83 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "35919",
5
    description => "Add record_sources table",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        unless ( TableExists('record_sources') ) {
11
            $dbh->do(
12
                q{
13
                CREATE TABLE `record_sources` (
14
                    `record_source_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary key for the `record_sources` table',
15
                    `name` text NOT NULL COMMENT 'User defined name for the record source',
16
                    `can_be_edited` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If records from this source can be edited',
17
                    PRIMARY KEY (`record_source_id`)
18
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
19
            }
20
            );
21
22
            say $out "Added new table 'record_sources'";
23
        }
24
25
        unless ( column_exists( 'biblio_metadata', 'record_source_id' ) ) {
26
            $dbh->do(
27
                q{
28
                    ALTER TABLE biblio_metadata
29
                        ADD COLUMN `record_source_id` int(11) NULL DEFAULT NULL
30
                        COMMENT 'The record source for the metadata'
31
                        AFTER timestamp
32
            }
33
            );
34
35
            say $out "Added new column 'biblio_metadata.record_source_id'";
36
        }
37
38
        unless ( foreign_key_exists( 'biblio_metadata', 'record_metadata_fk_2' ) ) {
39
            $dbh->do(
40
                q{
41
                ALTER TABLE biblio_metadata
42
                ADD CONSTRAINT `record_metadata_fk_2` FOREIGN KEY (`record_source_id`) REFERENCES `record_sources` (`record_source_id`) ON DELETE CASCADE ON UPDATE CASCADE
43
            }
44
            );
45
46
            say $out "Added new foreign key 'biblio_metadata.record_metadata_fk_2'";
47
        }
48
49
        unless ( column_exists( 'deletedbiblio_metadata', 'record_source_id' ) ) {
50
            $dbh->do(
51
                q{
52
                    ALTER TABLE deletedbiblio_metadata
53
                        ADD COLUMN `record_source_id` int(11) NULL DEFAULT NULL
54
                        COMMENT 'The record source for the metadata'
55
                        AFTER timestamp
56
            }
57
            );
58
59
            say $out "Added new column 'deletedbiblio_metadata.record_source_id'";
60
        }
61
62
        unless ( foreign_key_exists( 'deletedbiblio_metadata', 'deletedrecord_metadata_fk_2' ) ) {
63
            $dbh->do(
64
                q{
65
                ALTER TABLE deletedbiblio_metadata
66
                ADD CONSTRAINT `deletedrecord_metadata_fk_2` FOREIGN KEY (`record_source_id`) REFERENCES `record_sources` (`record_source_id`) ON DELETE CASCADE ON UPDATE CASCADE
67
            }
68
            );
69
70
            say $out "Added new foreign key 'deletedbiblio_metadata.record_metadata_fk_2'";
71
        }
72
73
        $dbh->do(
74
            q{
75
            INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
76
            ( 3, 'manage_record_sources', 'Manage record sources')
77
        }
78
        );
79
80
        say $out "Added new permission 'manage_record_sources'";
81
82
    },
83
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +21 lines)
Lines 1122-1127 CREATE TABLE `biblio_framework` ( Link Here
1122
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1122
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1123
/*!40101 SET character_set_client = @saved_cs_client */;
1123
/*!40101 SET character_set_client = @saved_cs_client */;
1124
1124
1125
--
1126
-- Table structure for table `record_sources`
1127
--
1128
1129
DROP TABLE IF EXISTS `record_sources`;
1130
/*!40101 SET @saved_cs_client     = @@character_set_client */;
1131
/*!40101 SET character_set_client = utf8 */;
1132
CREATE TABLE `record_sources` (
1133
  `record_source_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary key for the `record_sources` table',
1134
  `name` text NOT NULL COMMENT 'User defined name for the record source',
1135
  `can_be_edited` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If records from this source can be edited',
1136
  PRIMARY KEY (`record_source_id`)
1137
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1138
/*!40101 SET character_set_client = @saved_cs_client */;
1139
1125
--
1140
--
1126
-- Table structure for table `biblio_metadata`
1141
-- Table structure for table `biblio_metadata`
1127
--
1142
--
Lines 1136-1145 CREATE TABLE `biblio_metadata` ( Link Here
1136
  `schema` varchar(16) NOT NULL,
1151
  `schema` varchar(16) NOT NULL,
1137
  `metadata` longtext NOT NULL,
1152
  `metadata` longtext NOT NULL,
1138
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
1153
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
1154
  `record_source_id` int(11) NULL DEFAULT NULL COMMENT 'The record source for the metadata',
1139
  PRIMARY KEY (`id`),
1155
  PRIMARY KEY (`id`),
1140
  UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`schema`),
1156
  UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`schema`),
1141
  KEY `timestamp` (`timestamp`),
1157
  KEY `timestamp` (`timestamp`),
1142
  CONSTRAINT `record_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1158
  CONSTRAINT `record_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1159
  CONSTRAINT `record_metadata_fk_2` FOREIGN KEY (`record_source_id`) REFERENCES `record_sources` (`record_source_id`) ON DELETE CASCADE ON UPDATE CASCADE
1143
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1160
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1144
/*!40101 SET character_set_client = @saved_cs_client */;
1161
/*!40101 SET character_set_client = @saved_cs_client */;
1145
1162
Lines 2571-2580 CREATE TABLE `deletedbiblio_metadata` ( Link Here
2571
  `schema` varchar(16) NOT NULL,
2588
  `schema` varchar(16) NOT NULL,
2572
  `metadata` longtext NOT NULL,
2589
  `metadata` longtext NOT NULL,
2573
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2590
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2591
  `record_source_id` int(11) NULL DEFAULT NULL COMMENT 'The record source for the metadata',
2574
  PRIMARY KEY (`id`),
2592
  PRIMARY KEY (`id`),
2575
  UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`schema`),
2593
  UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`schema`),
2576
  KEY `timestamp` (`timestamp`),
2594
  KEY `timestamp` (`timestamp`),
2577
  CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `deletedbiblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2595
  CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `deletedbiblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2596
  CONSTRAINT `deletedrecord_metadata_fk_2` FOREIGN KEY (`record_source_id`) REFERENCES `record_sources` (`record_source_id`) ON DELETE CASCADE ON UPDATE CASCADE
2578
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2597
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2579
/*!40101 SET character_set_client = @saved_cs_client */;
2598
/*!40101 SET character_set_client = @saved_cs_client */;
2580
2599
(-)a/installer/data/mysql/mandatory/userpermissions.sql (-1 / +1 lines)
Lines 43-48 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
43
   ( 3, 'manage_curbside_pickups', 'Manage curbside pickups'),
43
   ( 3, 'manage_curbside_pickups', 'Manage curbside pickups'),
44
   ( 3, 'manage_search_filters', 'Manage custom search filters'),
44
   ( 3, 'manage_search_filters', 'Manage custom search filters'),
45
   ( 3, 'manage_identity_providers', 'Manage identity providers'),
45
   ( 3, 'manage_identity_providers', 'Manage identity providers'),
46
   ( 3, 'manage_record_sources', 'Manage record sources'),
46
   ( 4, 'delete_borrowers', 'Delete patrons'),
47
   ( 4, 'delete_borrowers', 'Delete patrons'),
47
   ( 4, 'edit_borrowers', 'Add, modify and view patron information'),
48
   ( 4, 'edit_borrowers', 'Add, modify and view patron information'),
48
   ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
49
   ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
49
- 

Return to bug 35919