Bugzilla – Attachment 115658 Details for
Bug 20447
Add support for MARC holdings records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20447: DBIX schema changes
Bug-20447-DBIX-schema-changes.patch (text/plain), 10.78 KB, created by
Andrii Nugged
on 2021-01-22 02:12:56 UTC
(
hide
)
Description:
Bug 20447: DBIX schema changes
Filename:
MIME Type:
Creator:
Andrii Nugged
Created:
2021-01-22 02:12:56 UTC
Size:
10.78 KB
patch
obsolete
>From ca251368361dedc700a690a272d048e5ad5f18f9 Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Wed, 20 Feb 2019 16:56:55 +0200 >Subject: [PATCH] Bug 20447: DBIX schema changes > >https://bugs.koha-community.org/show_bug.cgi?id=22690 >--- > Koha/Schema/Result/Biblio.pm | 15 ++ > Koha/Schema/Result/Branch.pm | 15 ++ > Koha/Schema/Result/Deleteditem.pm | 7 + > Koha/Schema/Result/Holding.pm | 234 +++++++++++++++++++++++++ > Koha/Schema/Result/HoldingsMetadata.pm | 138 +++++++++++++++ > Koha/Schema/Result/Item.pm | 28 +++ > 6 files changed, 437 insertions(+) > create mode 100644 Koha/Schema/Result/Holding.pm > create mode 100644 Koha/Schema/Result/HoldingsMetadata.pm > >diff --git a/Koha/Schema/Result/Biblio.pm b/Koha/Schema/Result/Biblio.pm >index 32ddcf2c15..e1cedfce3e 100644 >--- a/Koha/Schema/Result/Biblio.pm >+++ b/Koha/Schema/Result/Biblio.pm >@@ -300,6 +300,21 @@ __PACKAGE__->has_many( > { cascade_copy => 0, cascade_delete => 0 }, > ); > >+=head2 holdings >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Holding> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "holdings", >+ "Koha::Schema::Result::Holding", >+ { "foreign.biblionumber" => "self.biblionumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > =head2 items > > Type: has_many >diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm >index 87f4ec190f..ef767c6182 100644 >--- a/Koha/Schema/Result/Branch.pm >+++ b/Koha/Schema/Result/Branch.pm >@@ -631,6 +631,21 @@ __PACKAGE__->has_many( > { cascade_copy => 0, cascade_delete => 0 }, > ); > >+=head2 holdings >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Holding> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "holdings", >+ "Koha::Schema::Result::Holding", >+ { "foreign.holdingbranch" => "self.branchcode" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > =head2 illrequests > > Type: has_many >diff --git a/Koha/Schema/Result/Deleteditem.pm b/Koha/Schema/Result/Deleteditem.pm >index 12c8900c5a..91d26f147e 100644 >--- a/Koha/Schema/Result/Deleteditem.pm >+++ b/Koha/Schema/Result/Deleteditem.pm >@@ -370,6 +370,11 @@ inventory number (MARC21 952$i) > > Exclude this item from local holds priority > >+=head2 holding_id >+ >+ data_type: 'integer' >+ is_nullable: 1 >+ > =cut > > __PACKAGE__->add_columns( >@@ -480,6 +485,8 @@ __PACKAGE__->add_columns( > { data_type => "varchar", is_nullable => 1, size => 32 }, > "exclude_from_local_holds_priority", > { data_type => "tinyint", is_nullable => 1 }, >+ "holding_id", >+ { data_type => "integer", is_nullable => 1 }, > ); > > =head1 PRIMARY KEY >diff --git a/Koha/Schema/Result/Holding.pm b/Koha/Schema/Result/Holding.pm >new file mode 100644 >index 0000000000..0b2ae736a3 >--- /dev/null >+++ b/Koha/Schema/Result/Holding.pm >@@ -0,0 +1,234 @@ >+use utf8; >+package Koha::Schema::Result::Holding; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::Holding >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<holdings> >+ >+=cut >+ >+__PACKAGE__->table("holdings"); >+ >+=head1 ACCESSORS >+ >+=head2 holding_id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 biblionumber >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 frameworkcode >+ >+ data_type: 'varchar' >+ default_value: (empty string) >+ is_nullable: 0 >+ size: 4 >+ >+=head2 holdingbranch >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=head2 location >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 80 >+ >+=head2 ccode >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 80 >+ >+=head2 callnumber >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 255 >+ >+=head2 suppress >+ >+ data_type: 'tinyint' >+ is_nullable: 1 >+ >+=head2 timestamp >+ >+ data_type: 'timestamp' >+ datetime_undef_if_invalid: 1 >+ default_value: current_timestamp >+ is_nullable: 0 >+ >+=head2 datecreated >+ >+ data_type: 'date' >+ datetime_undef_if_invalid: 1 >+ is_nullable: 0 >+ >+=head2 deleted_on >+ >+ data_type: 'datetime' >+ datetime_undef_if_invalid: 1 >+ is_nullable: 1 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "holding_id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "biblionumber", >+ { >+ data_type => "integer", >+ default_value => 0, >+ is_foreign_key => 1, >+ is_nullable => 0, >+ }, >+ "frameworkcode", >+ { data_type => "varchar", default_value => "", is_nullable => 0, size => 4 }, >+ "holdingbranch", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, >+ "location", >+ { data_type => "varchar", is_nullable => 1, size => 80 }, >+ "ccode", >+ { data_type => "varchar", is_nullable => 1, size => 80 }, >+ "callnumber", >+ { data_type => "varchar", is_nullable => 1, size => 255 }, >+ "suppress", >+ { data_type => "tinyint", is_nullable => 1 }, >+ "timestamp", >+ { >+ data_type => "timestamp", >+ datetime_undef_if_invalid => 1, >+ default_value => \"current_timestamp", >+ is_nullable => 0, >+ }, >+ "datecreated", >+ { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 }, >+ "deleted_on", >+ { >+ data_type => "datetime", >+ datetime_undef_if_invalid => 1, >+ is_nullable => 1, >+ }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</holding_id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("holding_id"); >+ >+=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 holdingbranch >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "holdingbranch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "holdingbranch" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "RESTRICT", >+ on_update => "CASCADE", >+ }, >+); >+ >+=head2 holdings_metadatas >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::HoldingsMetadata> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "holdings_metadatas", >+ "Koha::Schema::Result::HoldingsMetadata", >+ { "foreign.holding_id" => "self.holding_id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 items >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Item> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "items", >+ "Koha::Schema::Result::Item", >+ { "foreign.holding_id" => "self.holding_id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-05-15 12:37:06 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:r5dS7lMIAG11s3PYFp/NKQ >+ >+=head2 metadata >+ >+This relationship makes it possible to use metadata as a prefetch table: >+ >+my $holdings = Koha::Holdings->search({}, {prefetch => 'metadata'}); >+my $metadata = $holdings->next()->metadata(); >+ >+=cut >+ >+__PACKAGE__->has_one( >+ "metadata", >+ "Koha::Schema::Result::HoldingsMetadata", >+ { "foreign.holding_id" => "self.holding_id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+1; >diff --git a/Koha/Schema/Result/HoldingsMetadata.pm b/Koha/Schema/Result/HoldingsMetadata.pm >new file mode 100644 >index 0000000000..42d7f886e5 >--- /dev/null >+++ b/Koha/Schema/Result/HoldingsMetadata.pm >@@ -0,0 +1,138 @@ >+use utf8; >+package Koha::Schema::Result::HoldingsMetadata; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::HoldingsMetadata >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<holdings_metadata> >+ >+=cut >+ >+__PACKAGE__->table("holdings_metadata"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 holding_id >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 format >+ >+ data_type: 'varchar' >+ is_nullable: 0 >+ size: 16 >+ >+=head2 schema >+ >+ data_type: 'varchar' >+ is_nullable: 0 >+ size: 16 >+ >+=head2 metadata >+ >+ data_type: 'longtext' >+ is_nullable: 0 >+ >+=head2 deleted_on >+ >+ data_type: 'datetime' >+ datetime_undef_if_invalid: 1 >+ is_nullable: 1 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "holding_id", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "format", >+ { data_type => "varchar", is_nullable => 0, size => 16 }, >+ "schema", >+ { data_type => "varchar", is_nullable => 0, size => 16 }, >+ "metadata", >+ { data_type => "longtext", is_nullable => 0 }, >+ "deleted_on", >+ { >+ data_type => "datetime", >+ datetime_undef_if_invalid => 1, >+ is_nullable => 1, >+ }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 UNIQUE CONSTRAINTS >+ >+=head2 C<holdings_metadata_uniq_key> >+ >+=over 4 >+ >+=item * L</holding_id> >+ >+=item * L</format> >+ >+=item * L</schema> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->add_unique_constraint( >+ "holdings_metadata_uniq_key", >+ ["holding_id", "format", "schema"], >+); >+ >+=head1 RELATIONS >+ >+=head2 holding >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Holding> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "holding", >+ "Koha::Schema::Result::Holding", >+ { holding_id => "holding_id" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07049 @ 2019-02-20 16:55:21 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:42bY17ncjs1OZKH23z4SgQ >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index 864095bcf6..68257b0aea 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -374,6 +374,12 @@ inventory number (MARC21 952$i) > > Exclude this item from local holds priority > >+=head2 holding_id >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ > =cut > > __PACKAGE__->add_columns( >@@ -494,6 +500,8 @@ __PACKAGE__->add_columns( > { data_type => "varchar", is_nullable => 1, size => 32 }, > "exclude_from_local_holds_priority", > { data_type => "tinyint", is_nullable => 1 }, >+ "holding_id", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, > ); > > =head1 PRIMARY KEY >@@ -674,6 +682,26 @@ __PACKAGE__->might_have( > { cascade_copy => 0, cascade_delete => 0 }, > ); > >+=head2 holding >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Holding> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "holding", >+ "Koha::Schema::Result::Holding", >+ { holding_id => "holding_id" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "CASCADE", >+ on_update => "CASCADE", >+ }, >+); >+ > =head2 holdingbranch > > Type: belongs_to >-- >2.30.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20447
:
73703
|
73704
|
76485
|
76542
|
76670
|
76671
|
76672
|
76735
|
76736
|
78178
|
78179
|
78180
|
78738
|
78739
|
78740
|
78907
|
79403
|
79413
|
79565
|
79566
|
79567
|
79568
|
79569
|
79570
|
79812
|
79813
|
79814
|
79815
|
79816
|
79819
|
80320
|
80321
|
80322
|
80323
|
80324
|
80823
|
80824
|
80825
|
80826
|
80827
|
81264
|
81265
|
81266
|
81267
|
81268
|
82669
|
82670
|
82671
|
82672
|
82673
|
83550
|
83551
|
83552
|
83553
|
83554
|
83555
|
83556
|
83557
|
83558
|
83559
|
85364
|
85368
|
85369
|
85370
|
85371
|
85416
|
85417
|
85418
|
85419
|
85906
|
85907
|
85908
|
85909
|
85994
|
85995
|
85996
|
85997
|
86088
|
86089
|
86090
|
86091
|
87307
|
87308
|
87309
|
87310
|
87346
|
87347
|
87348
|
87349
|
88751
|
88752
|
88753
|
88754
|
88755
|
91743
|
91744
|
91745
|
91746
|
91747
|
94539
|
94540
|
94541
|
94542
|
97796
|
97797
|
97798
|
97799
|
97800
|
97843
|
97844
|
97845
|
97846
|
99143
|
99144
|
99145
|
99146
|
99176
|
99177
|
99178
|
99179
|
99235
|
99236
|
99237
|
99238
|
99239
|
105068
|
105069
|
105070
|
105071
|
105072
|
105259
|
105260
|
105261
|
105262
|
105263
|
106147
|
106148
|
106149
|
106150
|
106151
|
108250
|
108251
|
108252
|
108253
|
108254
|
108255
|
108336
|
108337
|
108338
|
108339
|
108340
|
108341
|
108789
|
108790
|
108791
|
108792
|
108793
|
108794
|
109695
|
109696
|
109697
|
109698
|
109699
|
109700
|
109703
|
109704
|
109705
|
109706
|
109707
|
109708
|
109711
|
109712
|
109713
|
109714
|
109715
|
109717
|
109718
|
109719
|
109720
|
109721
|
109722
|
109741
|
109742
|
109743
|
109744
|
109745
|
109746
|
109765
|
109766
|
109767
|
109768
|
109769
|
109770
|
109873
|
109874
|
109875
|
109877
|
109878
|
109879
|
110115
|
110174
|
110313
|
110314
|
110315
|
110316
|
110317
|
110318
|
110319
|
110320
|
110467
|
110468
|
110469
|
110471
|
110472
|
110473
|
110474
|
110475
|
112176
|
112177
|
112179
|
112180
|
112181
|
112182
|
112189
|
112190
|
112191
|
112192
|
112193
|
112194
|
112570
|
112571
|
112572
|
112573
|
112574
|
112575
|
113943
|
113944
|
113945
|
113946
|
113947
|
113948
|
113952
|
113953
|
113954
|
113955
|
113956
|
113957
|
113958
|
113959
|
115239
|
115240
|
115241
|
115242
|
115243
|
115244
|
115245
|
115654
|
115655
|
115656
|
115657
|
115658
|
115659
|
115660
|
115722
|
115723
|
115724
|
115725
|
115726
|
115727
|
115728
|
115729
|
116797
|
116798
|
116799
|
116800
|
116801
|
116802
|
116803
|
116804
|
116805
|
116806
|
116807
|
116808
|
116809
|
116810
|
116811
|
116812
|
118382
|
118383
|
118385
|
118386
|
118387
|
118388
|
118389
|
118390
|
118397
|
118398
|
118399
|
118400
|
118401
|
118402
|
118403
|
118404
|
118405
|
118406
|
118407
|
118408
|
118409
|
118410
|
118411
|
118412
|
118429
|
118430
|
118431
|
118432
|
118433
|
118434
|
118435
|
118436
|
118527
|
118528
|
118529
|
118530
|
118531
|
118532
|
118533
|
118534
|
118535
|
118536
|
119265
|
119266
|
119267
|
119268
|
119269
|
119270
|
119271
|
119272
|
119273
|
119274
|
119514
|
119515
|
119516
|
119517
|
119518
|
119519
|
119520
|
119521
|
119522
|
119523
|
119570
|
119571
|
121216
|
121217
|
121220
|
121221
|
121222
|
121223
|
121226
|
121227
|
121228
|
121229
|
121230
|
121231
|
121379
|
121380
|
121381
|
121382
|
121383
|
121406
|
121407
|
121408
|
121409
|
121410
|
122501
|
122502
|
122503
|
122504
|
122505
|
122851
|
122852
|
122853
|
122854
|
122855
|
122856
|
122891
|
122892
|
122893
|
122894
|
122895
|
122896
|
122897
|
123047
|
123048
|
123049
|
123050
|
123051
|
123052
|
123053
|
123054
|
123055
|
123056
|
123057
|
123058
|
123059
|
123060
|
123061
|
124012
|
124013
|
124014
|
124015
|
124016
|
124017
|
124018
|
124944
|
124945
|
124946
|
124947
|
124948
|
124949
|
124950
|
126204
|
126205
|
126206
|
126207
|
126208
|
126209
|
126210
|
126211
|
126212
|
126296
|
126391
|
126392
|
126394
|
126395
|
126396
|
126397
|
126398
|
126399
|
126400
|
126401
|
126402
|
126403
|
126404
|
126405
|
126932
|
126933
|
126934
|
126935
|
126936
|
126937
|
126938
|
126939
|
126940
|
126941
|
126942
|
126943
|
127040
|
128079
|
128131
|
128134
|
130776
|
130777
|
130778
|
130779
|
130780
|
130781
|
130782
|
130783
|
130784
|
130785
|
130786
|
130787
|
130788
|
130789
|
130790
|
130791
|
130792
|
130793
|
130794
|
130795
|
130796
|
130797
|
130798
|
130799
|
130800
|
130801
|
130802
|
130803
|
130804
|
130805
|
130806
|
130807
|
131458
|
131459
|
131460
|
131461
|
131462
|
131463
|
131464
|
131465
|
131466
|
131467
|
131468
|
131469
|
131470
|
131471
|
131472
|
131473
|
131474
|
131475
|
131476
|
131477
|
131478
|
131479
|
131480
|
131481
|
131482
|
139865
|
139866
|
139867
|
139868
|
139869
|
139870
|
139871
|
139872
|
139873
|
139874
|
139875
|
139876
|
139877
|
139878
|
139879
|
139880
|
139881
|
139882
|
139883
|
139884
|
139885
|
139886
|
139887
|
139888
|
139889
|
139890
|
139891
|
139892
|
139893
|
139894
|
139895
|
139896
|
157492
|
157493