Bug 35044: DB changes + atomicupdate file
Add the 'repeatable' column to additional_fields Remove the unique key from additional_field_values as we will now be allowing for repeated instances of the same field_id + record_id Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
e27c3a6090
commit
53a50118ae
2 changed files with 47 additions and 1 deletions
45
installer/data/mysql/atomicupdate/bug_35044.pl
Executable file
45
installer/data/mysql/atomicupdate/bug_35044.pl
Executable file
|
@ -0,0 +1,45 @@
|
|||
use Modern::Perl;
|
||||
|
||||
return {
|
||||
bug_number => "35044",
|
||||
description => "Add repeatable option to additional_fields",
|
||||
up => sub {
|
||||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||
|
||||
unless ( column_exists( 'additional_fields', 'repeatable' ) ) {
|
||||
$dbh->do(
|
||||
q{
|
||||
ALTER TABLE additional_fields ADD COLUMN `repeatable` tinyint(1) NOT NULL DEFAULT 0 COMMENT
|
||||
'does the field allow more than one option?' AFTER searchable
|
||||
}
|
||||
);
|
||||
say $out "Added repeatable column to additional_fields table";
|
||||
}
|
||||
|
||||
if ( unique_key_exists ('additional_field_values', 'field_record') ) {
|
||||
# Need to drop foreign key so that we can then drop the unique key
|
||||
$dbh->do(
|
||||
q{
|
||||
ALTER TABLE additional_field_values DROP FOREIGN KEY afv_fk
|
||||
}
|
||||
);
|
||||
|
||||
# Drop the unique key
|
||||
$dbh->do(
|
||||
q{
|
||||
ALTER TABLE additional_field_values DROP INDEX field_record;
|
||||
}
|
||||
);
|
||||
|
||||
# Restore foreign key constraint
|
||||
$dbh->do(
|
||||
q{
|
||||
ALTER TABLE additional_field_values ADD CONSTRAINT `afv_fk` FOREIGN KEY(`field_id`) REFERENCES
|
||||
`additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
}
|
||||
);
|
||||
say $out "Removed UNIQUE KEY `field_record` (`field_id`,`record_id`) from the additional_field_values table";
|
||||
}
|
||||
},
|
||||
};
|
|
@ -245,7 +245,7 @@ CREATE TABLE `additional_field_values` (
|
|||
`record_id` int(11) NOT NULL COMMENT 'record_id',
|
||||
`value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value for this field',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `field_record` (`field_id`,`record_id`),
|
||||
KEY `afv_fk` (`field_id`),
|
||||
CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
@ -265,6 +265,7 @@ CREATE TABLE `additional_fields` (
|
|||
`marcfield` varchar(16) NOT NULL DEFAULT '' COMMENT 'contains the marc field to copied into the record',
|
||||
`marcfield_mode` enum('get','set') NOT NULL DEFAULT 'get' COMMENT 'mode of operation (get or set) for marcfield',
|
||||
`searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field searchable?',
|
||||
`repeatable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field repeatable?',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `fields_uniq` (`tablename`(191),`name`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
|
Loading…
Reference in a new issue