# - #4 : the developer version. The 4th number is the database subversion.
# used by developers when the database changes. updatedatabase take care of the changes itself
# and is automatically called by Auth.pm when needed.
-$VERSION = "19.12.00.075";
+$VERSION = "19.12.00.076";
sub version {
return $VERSION;
{ cascade_copy => 0, cascade_delete => 0 },
);
+=head2 serials
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Serial>
+
+=cut
+
+__PACKAGE__->has_many(
+ "serials",
+ "Koha::Schema::Result::Serial",
+ { "foreign.biblionumber" => "self.biblionumber" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 subscriptionhistories
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Subscriptionhistory>
+
+=cut
+
+__PACKAGE__->has_many(
+ "subscriptionhistories",
+ "Koha::Schema::Result::Subscriptionhistory",
+ { "foreign.biblionumber" => "self.biblionumber" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 subscriptions
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Subscription>
+
+=cut
+
+__PACKAGE__->has_many(
+ "subscriptions",
+ "Koha::Schema::Result::Subscription",
+ { "foreign.biblionumber" => "self.biblionumber" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
=head2 suggestions
Type: has_many
);
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:otCex8qzJmZyc+JXpKNdpQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-17 09:15:51
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:p2SIq565zPyE3ZUkSuXyBA
__PACKAGE__->has_one(
=head2 biblionumber
- data_type: 'varchar'
- default_value: (empty string)
+ data_type: 'integer'
+ is_foreign_key: 1
is_nullable: 0
- size: 100
=head2 subscriptionid
- data_type: 'varchar'
- default_value: (empty string)
+ data_type: 'integer'
+ is_foreign_key: 1
is_nullable: 0
- size: 100
=head2 serialseq
"serialid",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"biblionumber",
- { data_type => "varchar", default_value => "", is_nullable => 0, size => 100 },
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"subscriptionid",
- { data_type => "varchar", default_value => "", is_nullable => 0, size => 100 },
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"serialseq",
{ data_type => "varchar", default_value => "", is_nullable => 0, size => 100 },
"serialseq_x",
=head1 RELATIONS
+=head2 biblionumber
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Biblio>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "biblionumber",
+ "Koha::Schema::Result::Biblio",
+ { biblionumber => "biblionumber" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
=head2 serialitems
Type: has_many
{ cascade_copy => 0, cascade_delete => 0 },
);
+=head2 subscriptionid
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Subscription>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "subscriptionid",
+ "Koha::Schema::Result::Subscription",
+ { subscriptionid => "subscriptionid" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sRygXoIOnqpdk0lqVMcBdA
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-17 09:15:51
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ktCCJzkgRUFpYu857WQONA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
=head2 biblionumber
data_type: 'integer'
- default_value: 0
+ is_foreign_key: 1
is_nullable: 0
=head2 subscriptionid
__PACKAGE__->add_columns(
"biblionumber",
- { data_type => "integer", default_value => 0, is_nullable => 0 },
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"subscriptionid",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"librarian",
{ cascade_copy => 0, cascade_delete => 0 },
);
+=head2 biblionumber
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Biblio>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "biblionumber",
+ "Koha::Schema::Result::Biblio",
+ { biblionumber => "biblionumber" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
=head2 numberpattern
Type: belongs_to
},
);
+=head2 serials
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Serial>
+
+=cut
+
+__PACKAGE__->has_many(
+ "serials",
+ "Koha::Schema::Result::Serial",
+ { "foreign.subscriptionid" => "self.subscriptionid" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 subscriptionhistory
+
+Type: might_have
+
+Related object: L<Koha::Schema::Result::Subscriptionhistory>
+
+=cut
+
+__PACKAGE__->might_have(
+ "subscriptionhistory",
+ "Koha::Schema::Result::Subscriptionhistory",
+ { "foreign.subscriptionid" => "self.subscriptionid" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
=head2 subscriptionroutinglists
Type: has_many
);
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-15 11:35:38
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5zW2XKZNcvytO8svTJ4ijQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-17 09:15:51
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Bw7XzPSvv9fjc9F6+uIBUw
__PACKAGE__->has_many(
"additional_field_values",
=head2 biblionumber
data_type: 'integer'
- default_value: 0
+ is_foreign_key: 1
is_nullable: 0
=head2 subscriptionid
data_type: 'integer'
- default_value: 0
+ is_foreign_key: 1
is_nullable: 0
=head2 histstartdate
__PACKAGE__->add_columns(
"biblionumber",
- { data_type => "integer", default_value => 0, is_nullable => 0 },
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"subscriptionid",
- { data_type => "integer", default_value => 0, is_nullable => 0 },
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"histstartdate",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"histenddate",
__PACKAGE__->set_primary_key("subscriptionid");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-06-17 07:24:39
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SK33dc7lx/rDGX3tiR84ww
+=head2 biblionumber
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Biblio>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "biblionumber",
+ "Koha::Schema::Result::Biblio",
+ { biblionumber => "biblionumber" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+=head2 subscriptionid
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Subscription>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "subscriptionid",
+ "Koha::Schema::Result::Subscription",
+ { subscriptionid => "subscriptionid" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-17 09:15:51
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bcJbffy74eI1r+e4pImAwQ
sub koha_object_class {
'Koha::Subscription::History';
+++ /dev/null
-$DBversion = 'XXX'; # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-
- $dbh->do(q|
- UPDATE
- serial
- SET
- planneddate = NULL
- WHERE
- planneddate = '0000-00-00'
- |);
-
- $dbh->do(q|
- UPDATE
- serial
- SET
- publisheddate = NULL
- WHERE
- publisheddate = '0000-00-00'
- |);
-
- $dbh->do(q|
- UPDATE
- serial
- SET
- claimdate = NULL
- WHERE
- claimdate = '0000-00-00'
- |);
-
- $dbh->do(q|
- ALTER TABLE serial
- MODIFY COLUMN biblionumber INT(11) NOT NULL
- |);
-
- unless ( foreign_key_exists( 'serial', 'serial_ibfk_1' ) ) {
- my $serials = $dbh->selectall_arrayref(q|
- SELECT serialid FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
- |, { Slice => {} });
- if ( @$serials ) {
- warn q|WARNING - The following serials are deleted, they were not attached to an existing bibliographic record (serialid): | . join ", ", map { $_->{serialid} } @$serials;
- $dbh->do(q|
- DELETE FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
- |);
- }
- $dbh->do(q|
- ALTER TABLE serial
- ADD CONSTRAINT serial_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
- |);
- }
-
- $dbh->do(q|
- ALTER TABLE serial
- MODIFY COLUMN subscriptionid INT(11) NOT NULL
- |);
-
- unless ( foreign_key_exists( 'serial', 'serial_ibfk_2' ) ) {
- my $serials = $dbh->selectall_arrayref(q|
- SELECT serialid FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
- |, { Slice => {} });
- if ( @$serials ) {
- warn q|WARNING - The following serials are deleted, they were not attached to an existing subscription (serialid): | . join ", ", map { $_->{serialid} } @$serials;
- $dbh->do(q|
- DELETE FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
- |);
- }
- $dbh->do(q|
- ALTER TABLE serial
- ADD CONSTRAINT serial_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE
- |);
- }
-
- $dbh->do(q|
- ALTER TABLE subscriptionhistory
- MODIFY COLUMN biblionumber int(11) NOT NULL,
- MODIFY COLUMN subscriptionid int(11) NOT NULL
- |);
-
- unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_1' ) ) {
- $dbh->do(q|
- DELETE FROM subscriptionhistory WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
- |);
- $dbh->do(q|
- ALTER TABLE subscriptionhistory
- ADD CONSTRAINT subscription_history_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
- |);
- }
-
- unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_2' ) ) {
- $dbh->do(q|
- DELETE FROM subscriptionhistory WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
- |);
- $dbh->do(q|
- ALTER TABLE subscriptionhistory
- ADD CONSTRAINT subscription_history_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE
- |);
- }
-
- $dbh->do(q|
- ALTER TABLE subscription
- MODIFY COLUMN biblionumber int(11) NOT NULL
- |);
-
- unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_3' ) ) {
- my $subscriptions = $dbh->selectall_arrayref(q|
- SELECT subscriptionid FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
- |, { Slice => {} });
- if ( @$subscriptions ) {
- warn q|WARNING - The following subscriptions are deleted, they were not attached to an existing bibliographic record (subscriptionid): | . join ", ", map { $_->{subscriptionid} } @$subscriptions;
-
- $dbh->do(q|
- DELETE FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
- |);
- }
- $dbh->do(q|
- ALTER TABLE subscription
- ADD CONSTRAINT subscription_ibfk_3 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
- |);
- }
-
- SetVersion( $DBversion );
- print "Upgrade to $DBversion done (Bug 21901 - Add foreign key constraints on serial)\n";
-}
NewVersion( $DBversion, 25086, "Set changed_fields column of borrower_modifications as nullable");
}
+$DBversion = '19.12.00.076';
+if( CheckVersion( $DBversion ) ) {
+ my @warnings;
+
+ $dbh->do(q|
+ UPDATE
+ serial
+ SET
+ planneddate = NULL
+ WHERE
+ planneddate = '0000-00-00'
+ |);
+
+ $dbh->do(q|
+ UPDATE
+ serial
+ SET
+ publisheddate = NULL
+ WHERE
+ publisheddate = '0000-00-00'
+ |);
+
+ $dbh->do(q|
+ UPDATE
+ serial
+ SET
+ claimdate = NULL
+ WHERE
+ claimdate = '0000-00-00'
+ |);
+
+ $dbh->do(q|
+ ALTER TABLE serial
+ MODIFY COLUMN biblionumber INT(11) NOT NULL
+ |);
+
+ unless ( foreign_key_exists( 'serial', 'serial_ibfk_1' ) ) {
+ my $serials = $dbh->selectall_arrayref(q|
+ SELECT serialid FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
+ |, { Slice => {} });
+ if ( @$serials ) {
+ push @warnings, q|WARNING - The following serials are deleted, they were not attached to an existing bibliographic record (serialid): | . join ", ", map { $_->{serialid} } @$serials;
+ $dbh->do(q|
+ DELETE FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
+ |);
+ }
+ $dbh->do(q|
+ ALTER TABLE serial
+ ADD CONSTRAINT serial_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
+ |);
+ }
+
+ $dbh->do(q|
+ ALTER TABLE serial
+ MODIFY COLUMN subscriptionid INT(11) NOT NULL
+ |);
+
+ unless ( foreign_key_exists( 'serial', 'serial_ibfk_2' ) ) {
+ my $serials = $dbh->selectall_arrayref(q|
+ SELECT serialid FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
+ |, { Slice => {} });
+ if ( @$serials ) {
+ push @warnings, q|WARNING - The following serials are deleted, they were not attached to an existing subscription (serialid): | . join ", ", map { $_->{serialid} } @$serials;
+ $dbh->do(q|
+ DELETE FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
+ |);
+ }
+ $dbh->do(q|
+ ALTER TABLE serial
+ ADD CONSTRAINT serial_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE
+ |);
+ }
+
+ $dbh->do(q|
+ ALTER TABLE subscriptionhistory
+ MODIFY COLUMN biblionumber int(11) NOT NULL,
+ MODIFY COLUMN subscriptionid int(11) NOT NULL
+ |);
+
+ unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_1' ) ) {
+ $dbh->do(q|
+ DELETE FROM subscriptionhistory WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
+ |);
+ $dbh->do(q|
+ ALTER TABLE subscriptionhistory
+ ADD CONSTRAINT subscription_history_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
+ |);
+ }
+
+ unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_2' ) ) {
+ $dbh->do(q|
+ DELETE FROM subscriptionhistory WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
+ |);
+ $dbh->do(q|
+ ALTER TABLE subscriptionhistory
+ ADD CONSTRAINT subscription_history_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE
+ |);
+ }
+
+ $dbh->do(q|
+ ALTER TABLE subscription
+ MODIFY COLUMN biblionumber int(11) NOT NULL
+ |);
+
+ unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_3' ) ) {
+ my $subscriptions = $dbh->selectall_arrayref(q|
+ SELECT subscriptionid FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
+ |, { Slice => {} });
+ if ( @$subscriptions ) {
+ push @warnings, q|WARNING - The following subscriptions are deleted, they were not attached to an existing bibliographic record (subscriptionid): | . join ", ", map { $_->{subscriptionid} } @$subscriptions;
+
+ $dbh->do(q|
+ DELETE FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
+ |);
+ }
+ $dbh->do(q|
+ ALTER TABLE subscription
+ ADD CONSTRAINT subscription_ibfk_3 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
+ |);
+ }
+
+ for my $warning (@warnings) {
+ warn $warning;
+ }
+
+ my $description = [ "Add foreign key constraints on serial", @warnings ];
+ NewVersion( $DBversion, 21901, $description);
+}
+
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';