# - #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 = "18.12.00.015";
+$VERSION = "18.12.00.016";
sub version {
return $VERSION;
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
+=head2 illrequests
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:13:07
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YwvGOd/jzk71ekWfO56xrw
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Illrequest>
+
+=cut
+
+__PACKAGE__->has_many(
+ "illrequests",
+ "Koha::Schema::Result::Illrequest",
+ { "foreign.status_alias" => "self.authorised_value" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-22 14:32:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hDlebhEn+f+thqwBo/LOqQ
# You can replace this text with custom code or comments, and it will be preserved on regeneration
is_nullable: 1
size: 50
+=head2 status_alias
+
+ data_type: 'varchar'
+ is_foreign_key: 1
+ is_nullable: 1
+ size: 80
+
=head2 placed
data_type: 'date'
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 50 },
"status",
{ data_type => "varchar", is_nullable => 1, size => 50 },
+ "status_alias",
+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 80 },
"placed",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"replied",
{ cascade_copy => 0, cascade_delete => 0 },
);
+=head2 status_alias
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::AuthorisedValue>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "status_alias",
+ "Koha::Schema::Result::AuthorisedValue",
+ { authorised_value => "status_alias" },
+ {
+ is_deferrable => 1,
+ join_type => "LEFT",
+ on_delete => "SET NULL",
+ on_update => "CASCADE",
+ },
+);
+
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-27 13:16:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rv6QyhxEah2r/rDcz3aOOw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-22 14:32:49
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:I6fY8XRfEmRxSzOeVT9Krw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
+++ /dev/null
-$DBversion = 'XXX'; # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-
- if ( !column_exists( 'illrequests', 'status_alias' ) ) {
- # Fresh upgrade, just add the column and constraint
- $dbh->do( "ALTER TABLE illrequests ADD COLUMN status_alias varchar(80) DEFAULT NULL AFTER status" );
- } else {
- # Migrate all existing foreign keys from referencing authorised_values.id
- # to referencing authorised_values.authorised_value
- # First remove the foreign key constraint and index
- if ( foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
- $dbh->do( "ALTER TABLE illrequests DROP FOREIGN KEY illrequests_safk");
- }
- if ( index_exists( 'illrequests', 'illrequests_safk' ) ) {
- $dbh->do( "DROP INDEX illrequests_safk ON illrequests" );
- }
- # Now change the illrequests.status_alias column definition from int to varchar
- $dbh->do( "ALTER TABLE illrequests MODIFY COLUMN status_alias varchar(80)" );
- # Now replace all references to authorised_values.id with their
- # corresponding authorised_values.authorised_value
- my $sth = $dbh->prepare( "SELECT illrequest_id, status_alias FROM illrequests WHERE status_alias IS NOT NULL" );
- $sth->execute();
- while (my @row = $sth->fetchrow_array()) {
- my $r_id = $row[0];
- my $av_id = $row[1];
- # Get the authorised value's authorised_value value
- my ($av_val) = $dbh->selectrow_array( "SELECT authorised_value FROM authorised_values WHERE id = ?", {}, $av_id );
- # Now update illrequests.status_alias
- if ($av_val) {
- $dbh->do( "UPDATE illrequests SET status_alias = ? WHERE illrequest_id = ?", {}, ($av_val, $r_id) );
- }
- }
- }
- if ( !foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
- $dbh->do( "ALTER TABLE illrequests ADD CONSTRAINT illrequests_safk FOREIGN KEY (status_alias) REFERENCES authorised_values(authorised_value) ON UPDATE CASCADE ON DELETE SET NULL" );
- }
- $dbh->do( "INSERT IGNORE INTO authorised_value_categories SET category_name = 'ILLSTATUS'");
-
- SetVersion( $DBversion );
- print "Upgrade to $DBversion done (Bug 20581 - Allow manual selection of custom ILL request statuses)\n";
-}
print "Upgrade to $DBversion done (Bug 3820 - Update patron modification logs)\n";
}
+$DBversion = '18.12.00.016';
+if( CheckVersion( $DBversion ) ) {
+
+ if ( !column_exists( 'illrequests', 'status_alias' ) ) {
+ # Fresh upgrade, just add the column and constraint
+ $dbh->do( "ALTER TABLE illrequests ADD COLUMN status_alias varchar(80) DEFAULT NULL AFTER status" );
+ } else {
+ # Migrate all existing foreign keys from referencing authorised_values.id
+ # to referencing authorised_values.authorised_value
+ # First remove the foreign key constraint and index
+ if ( foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
+ $dbh->do( "ALTER TABLE illrequests DROP FOREIGN KEY illrequests_safk");
+ }
+ if ( index_exists( 'illrequests', 'illrequests_safk' ) ) {
+ $dbh->do( "DROP INDEX illrequests_safk ON illrequests" );
+ }
+ # Now change the illrequests.status_alias column definition from int to varchar
+ $dbh->do( "ALTER TABLE illrequests MODIFY COLUMN status_alias varchar(80)" );
+ # Now replace all references to authorised_values.id with their
+ # corresponding authorised_values.authorised_value
+ my $sth = $dbh->prepare( "SELECT illrequest_id, status_alias FROM illrequests WHERE status_alias IS NOT NULL" );
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array()) {
+ my $r_id = $row[0];
+ my $av_id = $row[1];
+ # Get the authorised value's authorised_value value
+ my ($av_val) = $dbh->selectrow_array( "SELECT authorised_value FROM authorised_values WHERE id = ?", {}, $av_id );
+ # Now update illrequests.status_alias
+ if ($av_val) {
+ $dbh->do( "UPDATE illrequests SET status_alias = ? WHERE illrequest_id = ?", {}, ($av_val, $r_id) );
+ }
+ }
+ }
+ if ( !foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
+ $dbh->do( "ALTER TABLE illrequests ADD CONSTRAINT illrequests_safk FOREIGN KEY (status_alias) REFERENCES authorised_values(authorised_value) ON UPDATE CASCADE ON DELETE SET NULL" );
+ }
+ $dbh->do( "INSERT IGNORE INTO authorised_value_categories SET category_name = 'ILLSTATUS'");
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20581 - Allow manual selection of custom ILL request statuses)\n";
+}
+
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.