Bug 26403: Move credit and debit types into translatable YAML files
[koha.git] / installer / data / mysql / db_revs / 211200013.pl
1 use Modern::Perl;
2
3 return {
4     bug_number  => "29605",
5     description => "Resync DB structure for existing installations",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out)};
9
10         if (   !primary_key_exists( 'language_script_mapping', 'language_subtag' )
11             and index_exists( 'language_script_mapping', 'language_subtag' ) ) {
12
13             $dbh->do(q{
14                 ALTER TABLE language_script_mapping
15                 DROP KEY `language_subtag`;
16             });
17         }
18
19         if ( !primary_key_exists( 'language_script_mapping', 'language_subtag' ) ) {
20
21             $dbh->do(q{
22                 ALTER TABLE language_script_mapping
23                 ADD PRIMARY KEY `language_subtag` (`language_subtag`);
24             });
25
26             say $out "Added missing primary key on language_script_mapping"
27         }
28
29         unless ( foreign_key_exists('tmp_holdsqueue', 'tmp_holdsqueue_ibfk_3') ) {
30             $dbh->do(q{
31                 ALTER TABLE tmp_holdsqueue
32                 ADD CONSTRAINT `tmp_holdsqueue_ibfk_3` FOREIGN KEY (`borrowernumber`)
33                 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
34             });
35
36             say $out "Added missing foreign key on tmp_holdsqueue";
37         }
38
39         $dbh->do(q{
40                 ALTER TABLE `account_offsets`
41                 MODIFY COLUMN `type` enum( 'CREATE', 'APPLY', 'VOID', 'OVERDUE_INCREASE', 'OVERDUE_DECREASE' ) NOT NULL
42         });
43         say $out "Ensure NOT NULL on account_offsets.type";
44
45         $dbh->do(q{
46                 ALTER TABLE `additional_contents`
47                 MODIFY COLUMN `code` VARCHAR(100) NOT NULL
48         });
49         say $out "Ensure additional_contents.code is VARCHAR(100)";
50
51         $dbh->do(q{
52                 ALTER TABLE `additional_contents`
53                 MODIFY COLUMN `lang` VARCHAR(50) NOT NULL DEFAULT ''
54         });
55         say $out "Ensure additional_contents.lang is VARCHAR(50)";
56
57         $dbh->do(q{
58             ALTER TABLE search_marc_map MODIFY `marc_type` enum('marc21','unimarc') NOT NULL COMMENT 'what MARC type this map is for'
59         });
60         say $out "Ensure NOT NULL on search_marc_map.marc_type";
61
62         $dbh->do(q{
63             alter table
64                 `branchtransfers`
65             modify column
66                 `cancellation_reason` enum(
67                     'Manual',
68                     'StockrotationAdvance',
69                     'StockrotationRepatriation',
70                     'ReturnToHome',
71                     'ReturnToHolding',
72                     'RotatingCollection',
73                     'Reserve',
74                     'LostReserve',
75                     'CancelReserve',
76                     'ItemLost',
77                     'WrongTransfer'
78                 ) DEFAULT NULL
79             after `reason`
80         });
81         say $out "Ensure branchtransfers.cancellation_reason enum values are uppercase";
82     },
83
84 };