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

(-)a/installer/data/mysql/atomicupdate/atomic_additional_fields.pl (+45 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "xxx",
5
    description => "Add repeatable option to additional_fields",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        unless ( column_exists( 'additional_fields', 'repeatable' ) ) {
11
            $dbh->do(
12
                q{
13
                    ALTER TABLE additional_fields ADD COLUMN `repeatable` tinyint(1) NOT NULL DEFAULT 0 COMMENT
14
                        'does the field allow more than one option?' AFTER searchable
15
                }
16
            );
17
            say $out "Added repeatable column to additional_fields table";
18
        }
19
20
        if ( unique_key_exists ('additional_field_values', 'afv_fk') ) {
21
            # Need to drop foreign key so that we can then drop the unique key
22
            $dbh->do(
23
                q{
24
                    ALTER TABLE additional_field_values DROP FOREIGN KEY afv_fk
25
                }
26
            );
27
28
            # Drop the unique key
29
            $dbh->do(
30
                q{
31
                    ALTER TABLE additional_field_values DROP INDEX field_record;
32
                }
33
            );
34
35
            # Restore foreign key constraint
36
            $dbh->do(
37
                q{
38
                    ALTER TABLE additional_field_values ADD CONSTRAINT `afv_fk` FOREIGN KEY(`field_id`) REFERENCES
39
                        `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
40
                }
41
            );
42
            say $out "Removed UNIQUE KEY `field_record` (`field_id`,`record_id`) from the additional_field_values table";
43
        }
44
    },
45
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 244-250 CREATE TABLE `additional_field_values` ( Link Here
244
  `record_id` int(11) NOT NULL COMMENT 'record_id',
244
  `record_id` int(11) NOT NULL COMMENT 'record_id',
245
  `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value for this field',
245
  `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value for this field',
246
  PRIMARY KEY (`id`),
246
  PRIMARY KEY (`id`),
247
  UNIQUE KEY `field_record` (`field_id`,`record_id`),
247
  KEY `afv_fk` (`field_id`),
248
  CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
248
  CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
249
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
249
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
250
/*!40101 SET character_set_client = @saved_cs_client */;
250
/*!40101 SET character_set_client = @saved_cs_client */;
Lines 264-269 CREATE TABLE `additional_fields` ( Link Here
264
  `marcfield` varchar(16) NOT NULL DEFAULT '' COMMENT 'contains the marc field to copied into the record',
264
  `marcfield` varchar(16) NOT NULL DEFAULT '' COMMENT 'contains the marc field to copied into the record',
265
  `marcfield_mode` enum('get','set') NOT NULL DEFAULT 'get' COMMENT 'mode of operation (get or set) for marcfield',
265
  `marcfield_mode` enum('get','set') NOT NULL DEFAULT 'get' COMMENT 'mode of operation (get or set) for marcfield',
266
  `searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field searchable?',
266
  `searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field searchable?',
267
  `repeatable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field repeatable?',
267
  PRIMARY KEY (`id`),
268
  PRIMARY KEY (`id`),
268
  UNIQUE KEY `fields_uniq` (`tablename`(191),`name`(191))
269
  UNIQUE KEY `fields_uniq` (`tablename`(191),`name`(191))
269
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
270
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
270
- 

Return to bug 35044