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

(-)a/installer/data/mysql/atomicupdate/bug_38256-link_vendors_to_data_providers.pl (+37 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  => "38256",
6
    description => "Link vendors to data providers",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        unless ( column_exists( 'erm_usage_data_providers', 'vendor_id' ) ) {
12
            $dbh->do(
13
                q{
14
                    ALTER TABLE erm_usage_data_providers
15
                        ADD COLUMN `vendor_id` int(11) DEFAULT NULL
16
                        COMMENT 'the vendor linked to this provider'
17
                        AFTER service_platform
18
            }
19
            );
20
21
            say $out "Added new column 'erm_usage_data_providers.vendor'";
22
        }
23
24
        unless ( foreign_key_exists( 'erm_usage_data_providers', 'erm_usage_data_providers_ibfk_1' ) ) {
25
            $dbh->do(
26
                q{
27
                    ALTER TABLE erm_usage_data_providers
28
                    ADD CONSTRAINT `erm_usage_data_providers_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
29
                }
30
                ) == 1
31
                && say_success(
32
                $out,
33
                "Added foreign key 'erm_usage_data_providers_ibfk_1' to column 'erm_usage_data_providers.vendor_id'"
34
                );
35
        }
36
    },
37
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +4 lines)
Lines 3230-3236 CREATE TABLE `erm_usage_data_providers` ( Link Here
3230
  `requestor_email` varchar(80) DEFAULT NULL COMMENT 'requestor email',
3230
  `requestor_email` varchar(80) DEFAULT NULL COMMENT 'requestor email',
3231
  `report_types` varchar(255) DEFAULT NULL COMMENT 'report types provided by the harvester',
3231
  `report_types` varchar(255) DEFAULT NULL COMMENT 'report types provided by the harvester',
3232
  `service_platform` varchar(80) DEFAULT NULL COMMENT 'platform if provider requires it',
3232
  `service_platform` varchar(80) DEFAULT NULL COMMENT 'platform if provider requires it',
3233
  PRIMARY KEY (`erm_usage_data_provider_id`)
3233
  `vendor_id` int(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
3234
  PRIMARY KEY (`erm_usage_data_provider_id`),
3235
  KEY `erm_usage_data_provider_ibfk_1` (`vendor_id`),
3236
  CONSTRAINT `erm_usage_data_provider_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
3234
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3237
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3235
/*!40101 SET character_set_client = @saved_cs_client */;
3238
/*!40101 SET character_set_client = @saved_cs_client */;
3236
3239
3237
- 

Return to bug 38256