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

(-)a/Koha/Acquisition/Bookseller.pm (-3 / +2 lines)
Lines 74-82 Returns the list of subscriptions for the vendor Link Here
74
74
75
sub subscriptions {
75
sub subscriptions {
76
    my ($self) = @_;
76
    my ($self) = @_;
77
77
    my $booksellers_rs = $self->_result->subscriptions;
78
    # FIXME FK missing at DB level
78
    return Koha::Subscriptions->_new_from_dbic($booksellers_rs);
79
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
80
}
79
}
81
80
82
=head3 aliases
81
=head3 aliases
(-)a/Koha/Schema/Result/Aqbookseller.pm (-2 / +17 lines)
Lines 494-499 __PACKAGE__->belongs_to( Link Here
494
  },
494
  },
495
);
495
);
496
496
497
=head2 subscriptions
498
499
Type: has_many
500
501
Related object: L<Koha::Schema::Result::Subscription>
502
503
=cut
504
505
__PACKAGE__->has_many(
506
  "subscriptions",
507
  "Koha::Schema::Result::Subscription",
508
  { "foreign.aqbooksellerid" => "self.id" },
509
  { cascade_copy => 0, cascade_delete => 0 },
510
);
511
497
=head2 vendor_edi_accounts
512
=head2 vendor_edi_accounts
498
513
499
Type: has_many
514
Type: has_many
Lines 510-517 __PACKAGE__->has_many( Link Here
510
);
525
);
511
526
512
527
513
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-06-30 09:54:35
528
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-09-11 09:24:20
514
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xjeOqpcdN3Kb1wmLGDjzLg
529
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BAp8LQbC16KTLoV2ZDtRsQ
515
530
516
__PACKAGE__->add_columns(
531
__PACKAGE__->add_columns(
517
    '+active' => { is_boolean => 1 },
532
    '+active' => { is_boolean => 1 },
(-)a/Koha/Schema/Result/Subscription.pm (-4 / +24 lines)
Lines 59-65 start date for this subscription Link Here
59
=head2 aqbooksellerid
59
=head2 aqbooksellerid
60
60
61
  data_type: 'integer'
61
  data_type: 'integer'
62
  default_value: 0
62
  is_foreign_key: 1
63
  is_nullable: 1
63
  is_nullable: 1
64
64
65
foreign key for aqbooksellers.id to link to the vendor
65
foreign key for aqbooksellers.id to link to the vendor
Lines 353-359 __PACKAGE__->add_columns( Link Here
353
  "startdate",
353
  "startdate",
354
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
354
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
355
  "aqbooksellerid",
355
  "aqbooksellerid",
356
  { data_type => "integer", default_value => 0, is_nullable => 1 },
356
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
357
  "cost",
357
  "cost",
358
  { data_type => "integer", default_value => 0, is_nullable => 1 },
358
  { data_type => "integer", default_value => 0, is_nullable => 1 },
359
  "aqbudgetid",
359
  "aqbudgetid",
Lines 450-455 __PACKAGE__->set_primary_key("subscriptionid"); Link Here
450
450
451
=head1 RELATIONS
451
=head1 RELATIONS
452
452
453
=head2 aqbooksellerid
454
455
Type: belongs_to
456
457
Related object: L<Koha::Schema::Result::Aqbookseller>
458
459
=cut
460
461
__PACKAGE__->belongs_to(
462
  "aqbooksellerid",
463
  "Koha::Schema::Result::Aqbookseller",
464
  { id => "aqbooksellerid" },
465
  {
466
    is_deferrable => 1,
467
    join_type     => "LEFT",
468
    on_delete     => "SET NULL",
469
    on_update     => "CASCADE",
470
  },
471
);
472
453
=head2 aqorders
473
=head2 aqorders
454
474
455
Type: has_many
475
Type: has_many
Lines 566-573 __PACKAGE__->has_many( Link Here
566
);
586
);
567
587
568
588
569
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-07-14 11:46:15
589
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-09-11 09:24:20
570
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LICIiWzag365cUAq5OYD2A
590
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mi3Uxt+shIeD869VpcRV4A
571
591
572
__PACKAGE__->has_many(
592
__PACKAGE__->has_many(
573
  "additional_field_values",
593
  "additional_field_values",
(-)a/api/v1/swagger/definitions/vendor.yaml (+3 lines)
Lines 119-124 properties: Link Here
119
    description: List of aliases
119
    description: List of aliases
120
    items:
120
    items:
121
      $ref: "vendor_alias.yaml"
121
      $ref: "vendor_alias.yaml"
122
  subscriptions:
123
    type: array
124
    description: List of subscriptions
122
additionalProperties: false
125
additionalProperties: false
123
required:
126
required:
124
  - name
127
  - name
(-)a/api/v1/swagger/paths/acquisitions_vendors.yaml (+1 lines)
Lines 35-40 Link Here
35
          type: string
35
          type: string
36
          enum:
36
          enum:
37
            - aliases
37
            - aliases
38
            - subscriptions
38
        collectionFormat: csv
39
        collectionFormat: csv
39
    responses:
40
    responses:
40
      "200":
41
      "200":
(-)a/installer/data/mysql/atomicupdate/bug_38011-add_fk_to_subscriptions.pl (+26 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "BUG_NUMBER",
6
    description => "Add missing foreign key to subscription table",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_4' ) ) {
12
13
            $dbh->do(
14
                q|
15
                ALTER TABLE subscription
16
                ADD CONSTRAINT  subscription_ibfk_4
17
                    FOREIGN KEY (aqbooksellerid)
18
                    REFERENCES aqbooksellers (id) ON DELETE SET NULL ON UPDATE CASCADE
19
            |
20
            );
21
            say_success( $out, "Updated foreign key 'subscription_ibfk_4'" );
22
        } else {
23
            say_warning( $out, "Foreign key 'subscription_ibfk_4' already exists" );
24
        }
25
    },
26
};
(-)a/installer/data/mysql/kohastructure.sql (-3 / +4 lines)
Lines 5994-6000 CREATE TABLE `subscription` ( Link Here
5994
  `subscriptionid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for this subscription',
5994
  `subscriptionid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for this subscription',
5995
  `librarian` varchar(100) DEFAULT '' COMMENT 'the librarian''s username from borrowers.userid',
5995
  `librarian` varchar(100) DEFAULT '' COMMENT 'the librarian''s username from borrowers.userid',
5996
  `startdate` date DEFAULT NULL COMMENT 'start date for this subscription',
5996
  `startdate` date DEFAULT NULL COMMENT 'start date for this subscription',
5997
  `aqbooksellerid` int(11) DEFAULT 0 COMMENT 'foreign key for aqbooksellers.id to link to the vendor',
5997
  `aqbooksellerid` int(11) DEFAULT NULL COMMENT 'foreign key for aqbooksellers.id to link to the vendor',
5998
  `cost` int(11) DEFAULT 0,
5998
  `cost` int(11) DEFAULT 0,
5999
  `aqbudgetid` int(11) DEFAULT 0,
5999
  `aqbudgetid` int(11) DEFAULT 0,
6000
  `weeklength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if monthlength or numberlength is set)',
6000
  `weeklength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if monthlength or numberlength is set)',
Lines 6039-6047 CREATE TABLE `subscription` ( Link Here
6039
  KEY `subscription_ibfk_1` (`periodicity`),
6039
  KEY `subscription_ibfk_1` (`periodicity`),
6040
  KEY `subscription_ibfk_2` (`numberpattern`),
6040
  KEY `subscription_ibfk_2` (`numberpattern`),
6041
  KEY `subscription_ibfk_3` (`biblionumber`),
6041
  KEY `subscription_ibfk_3` (`biblionumber`),
6042
  KEY `subscription_ibfk_4` (`aqbooksellerid`),
6042
  CONSTRAINT `subscription_ibfk_1` FOREIGN KEY (`periodicity`) REFERENCES `subscription_frequencies` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
6043
  CONSTRAINT `subscription_ibfk_1` FOREIGN KEY (`periodicity`) REFERENCES `subscription_frequencies` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
6043
  CONSTRAINT `subscription_ibfk_2` FOREIGN KEY (`numberpattern`) REFERENCES `subscription_numberpatterns` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
6044
  CONSTRAINT `subscription_ibfk_2` FOREIGN KEY (`numberpattern`) REFERENCES `subscription_numberpatterns` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
6044
  CONSTRAINT `subscription_ibfk_3` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
6045
  CONSTRAINT `subscription_ibfk_3` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
6046
  CONSTRAINT `subscription_ibfk_4` FOREIGN KEY (`aqbooksellerid`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
6045
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6047
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6046
/*!40101 SET character_set_client = @saved_cs_client */;
6048
/*!40101 SET character_set_client = @saved_cs_client */;
6047
6049
6048
- 

Return to bug 38011