From 7e53060ddaa320b238ec54dde0f01034c1ccb035 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Tue, 15 Jul 2014 10:39:25 -0400
Subject: [PATCH] Bug 6427 - Update schema files

---
 Koha/Schema/Result/AccountCredit.pm |  200 +++++++++++++++++++++++++++
 Koha/Schema/Result/AccountDebit.pm  |  261 +++++++++++++++++++++++++++++++++++
 Koha/Schema/Result/AccountOffset.pm |  147 ++++++++++++++++++++
 Koha/Schema/Result/Borrower.pm      |   30 +++--
 Koha/Schema/Result/Branch.pm        |   32 ++++-
 Koha/Schema/Result/Deleteditem.pm   |   11 ++
 Koha/Schema/Result/Issue.pm         |   33 ++++-
 Koha/Schema/Result/Item.pm          |   15 --
 Koha/Schema/Result/OldIssue.pm      |   48 +++++++-
 9 files changed, 747 insertions(+), 30 deletions(-)
 create mode 100644 Koha/Schema/Result/AccountCredit.pm
 create mode 100644 Koha/Schema/Result/AccountDebit.pm
 create mode 100644 Koha/Schema/Result/AccountOffset.pm

diff --git a/Koha/Schema/Result/AccountCredit.pm b/Koha/Schema/Result/AccountCredit.pm
new file mode 100644
index 0000000..ebe13ab
--- /dev/null
+++ b/Koha/Schema/Result/AccountCredit.pm
@@ -0,0 +1,200 @@
+use utf8;
+package Koha::Schema::Result::AccountCredit;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Koha::Schema::Result::AccountCredit
+
+=cut
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+=head1 TABLE: C<account_credits>
+
+=cut
+
+__PACKAGE__->table("account_credits");
+
+=head1 ACCESSORS
+
+=head2 credit_id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+
+=head2 borrowernumber
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 0
+
+=head2 type
+
+  data_type: 'varchar'
+  is_nullable: 0
+  size: 255
+
+=head2 amount_received
+
+  data_type: 'decimal'
+  is_nullable: 1
+  size: [28,6]
+
+=head2 amount_paid
+
+  data_type: 'decimal'
+  is_nullable: 0
+  size: [28,6]
+
+=head2 amount_remaining
+
+  data_type: 'decimal'
+  is_nullable: 0
+  size: [28,6]
+
+=head2 notes
+
+  data_type: 'text'
+  is_nullable: 1
+
+=head2 branchcode
+
+  data_type: 'varchar'
+  is_foreign_key: 1
+  is_nullable: 1
+  size: 10
+
+=head2 manager_id
+
+  data_type: 'integer'
+  is_nullable: 1
+
+=head2 created_on
+
+  data_type: 'timestamp'
+  datetime_undef_if_invalid: 1
+  is_nullable: 1
+
+=head2 updated_on
+
+  data_type: 'timestamp'
+  datetime_undef_if_invalid: 1
+  is_nullable: 1
+
+=cut
+
+__PACKAGE__->add_columns(
+  "credit_id",
+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
+  "borrowernumber",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+  "type",
+  { data_type => "varchar", is_nullable => 0, size => 255 },
+  "amount_received",
+  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
+  "amount_paid",
+  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
+  "amount_remaining",
+  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
+  "notes",
+  { data_type => "text", is_nullable => 1 },
+  "branchcode",
+  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
+  "manager_id",
+  { data_type => "integer", is_nullable => 1 },
+  "created_on",
+  {
+    data_type => "timestamp",
+    datetime_undef_if_invalid => 1,
+    is_nullable => 1,
+  },
+  "updated_on",
+  {
+    data_type => "timestamp",
+    datetime_undef_if_invalid => 1,
+    is_nullable => 1,
+  },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</credit_id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("credit_id");
+
+=head1 RELATIONS
+
+=head2 account_offsets
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::AccountOffset>
+
+=cut
+
+__PACKAGE__->has_many(
+  "account_offsets",
+  "Koha::Schema::Result::AccountOffset",
+  { "foreign.credit_id" => "self.credit_id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 borrowernumber
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Borrower>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "borrowernumber",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "borrowernumber" },
+  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+=head2 branchcode
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Branch>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "branchcode",
+  "Koha::Schema::Result::Branch",
+  { branchcode => "branchcode" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "CASCADE",
+    on_update     => "CASCADE",
+  },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07040 @ 2014-07-15 10:08:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lkoQZ4EQDlmD9vpZQ7k7mA
+
+__PACKAGE__->belongs_to(
+  "borrower",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "borrowernumber" },
+);
+
+1;
diff --git a/Koha/Schema/Result/AccountDebit.pm b/Koha/Schema/Result/AccountDebit.pm
new file mode 100644
index 0000000..6c5e629
--- /dev/null
+++ b/Koha/Schema/Result/AccountDebit.pm
@@ -0,0 +1,261 @@
+use utf8;
+package Koha::Schema::Result::AccountDebit;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Koha::Schema::Result::AccountDebit
+
+=cut
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+=head1 TABLE: C<account_debits>
+
+=cut
+
+__PACKAGE__->table("account_debits");
+
+=head1 ACCESSORS
+
+=head2 debit_id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+
+=head2 borrowernumber
+
+  data_type: 'integer'
+  default_value: 0
+  is_foreign_key: 1
+  is_nullable: 0
+
+=head2 itemnumber
+
+  data_type: 'integer'
+  is_nullable: 1
+
+=head2 issue_id
+
+  data_type: 'integer'
+  is_nullable: 1
+
+=head2 type
+
+  data_type: 'varchar'
+  is_nullable: 0
+  size: 255
+
+=head2 accruing
+
+  data_type: 'tinyint'
+  default_value: 0
+  is_nullable: 0
+
+=head2 amount_original
+
+  data_type: 'decimal'
+  is_nullable: 1
+  size: [28,6]
+
+=head2 amount_outstanding
+
+  data_type: 'decimal'
+  is_nullable: 1
+  size: [28,6]
+
+=head2 amount_last_increment
+
+  data_type: 'decimal'
+  is_nullable: 1
+  size: [28,6]
+
+=head2 description
+
+  data_type: 'mediumtext'
+  is_nullable: 1
+
+=head2 notes
+
+  data_type: 'text'
+  is_nullable: 1
+
+=head2 branchcode
+
+  data_type: 'varchar'
+  is_foreign_key: 1
+  is_nullable: 1
+  size: 10
+
+=head2 manager_id
+
+  data_type: 'integer'
+  is_nullable: 1
+
+=head2 created_on
+
+  data_type: 'timestamp'
+  datetime_undef_if_invalid: 1
+  is_nullable: 1
+
+=head2 updated_on
+
+  data_type: 'timestamp'
+  datetime_undef_if_invalid: 1
+  is_nullable: 1
+
+=cut
+
+__PACKAGE__->add_columns(
+  "debit_id",
+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
+  "borrowernumber",
+  {
+    data_type      => "integer",
+    default_value  => 0,
+    is_foreign_key => 1,
+    is_nullable    => 0,
+  },
+  "itemnumber",
+  { data_type => "integer", is_nullable => 1 },
+  "issue_id",
+  { data_type => "integer", is_nullable => 1 },
+  "type",
+  { data_type => "varchar", is_nullable => 0, size => 255 },
+  "accruing",
+  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
+  "amount_original",
+  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
+  "amount_outstanding",
+  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
+  "amount_last_increment",
+  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
+  "description",
+  { data_type => "mediumtext", is_nullable => 1 },
+  "notes",
+  { data_type => "text", is_nullable => 1 },
+  "branchcode",
+  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
+  "manager_id",
+  { data_type => "integer", is_nullable => 1 },
+  "created_on",
+  {
+    data_type => "timestamp",
+    datetime_undef_if_invalid => 1,
+    is_nullable => 1,
+  },
+  "updated_on",
+  {
+    data_type => "timestamp",
+    datetime_undef_if_invalid => 1,
+    is_nullable => 1,
+  },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</debit_id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("debit_id");
+
+=head1 RELATIONS
+
+=head2 account_offsets
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::AccountOffset>
+
+=cut
+
+__PACKAGE__->has_many(
+  "account_offsets",
+  "Koha::Schema::Result::AccountOffset",
+  { "foreign.debit_id" => "self.debit_id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 borrowernumber
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Borrower>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "borrowernumber",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "borrowernumber" },
+  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+=head2 branchcode
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Branch>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "branchcode",
+  "Koha::Schema::Result::Branch",
+  { branchcode => "branchcode" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "CASCADE",
+    on_update     => "CASCADE",
+  },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07040 @ 2014-07-15 10:03:44
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ns19xWix5RriwDPelPnhfw
+
+__PACKAGE__->belongs_to(
+  "item",
+  "Koha::Schema::Result::Item",
+  { itemnumber => "itemnumber" }
+);
+
+__PACKAGE__->belongs_to(
+  "deleted_item",
+  "Koha::Schema::Result::Deleteditem",
+  { itemnumber => "itemnumber" }
+);
+
+__PACKAGE__->belongs_to(
+  "issue",
+  "Koha::Schema::Result::Issue",
+  { issue_id => "issue_id" }
+);
+
+__PACKAGE__->belongs_to(
+  "old_issue",
+  "Koha::Schema::Result::OldIssue",
+  { issue_id => "issue_id" }
+);
+
+__PACKAGE__->belongs_to(
+  "borrower",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "borrowernumber" },
+  { on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
diff --git a/Koha/Schema/Result/AccountOffset.pm b/Koha/Schema/Result/AccountOffset.pm
new file mode 100644
index 0000000..baabeac
--- /dev/null
+++ b/Koha/Schema/Result/AccountOffset.pm
@@ -0,0 +1,147 @@
+use utf8;
+package Koha::Schema::Result::AccountOffset;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Koha::Schema::Result::AccountOffset
+
+=cut
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+=head1 TABLE: C<account_offsets>
+
+=cut
+
+__PACKAGE__->table("account_offsets");
+
+=head1 ACCESSORS
+
+=head2 offset_id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+
+=head2 debit_id
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 1
+
+=head2 credit_id
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 1
+
+=head2 type
+
+  data_type: 'varchar'
+  is_nullable: 1
+  size: 255
+
+=head2 amount
+
+  data_type: 'decimal'
+  is_nullable: 0
+  size: [28,6]
+
+A positive number here represents a payment, a negative is a increase in a fine.
+
+=head2 created_on
+
+  data_type: 'timestamp'
+  datetime_undef_if_invalid: 1
+  default_value: current_timestamp
+  is_nullable: 0
+
+=cut
+
+__PACKAGE__->add_columns(
+  "offset_id",
+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
+  "debit_id",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
+  "credit_id",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
+  "type",
+  { data_type => "varchar", is_nullable => 1, size => 255 },
+  "amount",
+  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
+  "created_on",
+  {
+    data_type => "timestamp",
+    datetime_undef_if_invalid => 1,
+    default_value => \"current_timestamp",
+    is_nullable => 0,
+  },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</offset_id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("offset_id");
+
+=head1 RELATIONS
+
+=head2 credit
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::AccountCredit>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "credit",
+  "Koha::Schema::Result::AccountCredit",
+  { credit_id => "credit_id" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "CASCADE",
+    on_update     => "CASCADE",
+  },
+);
+
+=head2 debit
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::AccountDebit>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "debit",
+  "Koha::Schema::Result::AccountDebit",
+  { debit_id => "debit_id" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "CASCADE",
+    on_update     => "CASCADE",
+  },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07040 @ 2014-07-15 10:03:45
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CQJiVGoCnQEzkVu9ssgU/Q
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm
index 48102dd..ae0aa20 100644
--- a/Koha/Schema/Result/Borrower.pm
+++ b/Koha/Schema/Result/Borrower.pm
@@ -407,6 +407,12 @@ __PACKAGE__->table("borrowers");
   default_value: 1
   is_nullable: 0
 
+=head2 account_balance
+
+  data_type: 'decimal'
+  is_nullable: 0
+  size: [28,6]
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -576,6 +582,8 @@ __PACKAGE__->add_columns(
   { data_type => "varchar", is_nullable => 1, size => 50 },
   "privacy",
   { data_type => "integer", default_value => 1, is_nullable => 0 },
+  "account_balance",
+  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
 );
 
 =head1 PRIMARY KEY
@@ -606,32 +614,32 @@ __PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]);
 
 =head1 RELATIONS
 
-=head2 accountlines
+=head2 account_credits
 
 Type: has_many
 
-Related object: L<Koha::Schema::Result::Accountline>
+Related object: L<Koha::Schema::Result::AccountCredit>
 
 =cut
 
 __PACKAGE__->has_many(
-  "accountlines",
-  "Koha::Schema::Result::Accountline",
+  "account_credits",
+  "Koha::Schema::Result::AccountCredit",
   { "foreign.borrowernumber" => "self.borrowernumber" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
-=head2 accountoffsets
+=head2 account_debits
 
 Type: has_many
 
-Related object: L<Koha::Schema::Result::Accountoffset>
+Related object: L<Koha::Schema::Result::AccountDebit>
 
 =cut
 
 __PACKAGE__->has_many(
-  "accountoffsets",
-  "Koha::Schema::Result::Accountoffset",
+  "account_debits",
+  "Koha::Schema::Result::AccountDebit",
   { "foreign.borrowernumber" => "self.borrowernumber" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
@@ -1105,6 +1113,10 @@ __PACKAGE__->many_to_many("courses", "course_instructors", "course");
 # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-08-18 13:01:05
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZzZiKYN4b/LuEARX4rawhA
 
+__PACKAGE__->belongs_to(
+    "branch",
+    "Koha::Schema::Result::Branch",
+    { branchcode => "branchcode" },
+);
 
-# You can replace this text with custom content, and it will be preserved on regeneration
 1;
diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm
index 68a92d9..9e568da 100644
--- a/Koha/Schema/Result/Branch.pm
+++ b/Koha/Schema/Result/Branch.pm
@@ -187,6 +187,36 @@ __PACKAGE__->set_primary_key("branchcode");
 
 =head1 RELATIONS
 
+=head2 account_credits
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::AccountCredit>
+
+=cut
+
+__PACKAGE__->has_many(
+  "account_credits",
+  "Koha::Schema::Result::AccountCredit",
+  { "foreign.branchcode" => "self.branchcode" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 account_debits
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::AccountDebit>
+
+=cut
+
+__PACKAGE__->has_many(
+  "account_debits",
+  "Koha::Schema::Result::AccountDebit",
+  { "foreign.branchcode" => "self.branchcode" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 aqbaskets
 
 Type: has_many
@@ -502,5 +532,5 @@ __PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WRCu1ThkQVx+o7/ECe0j2A
 
 
-# You can replace this text with custom content, and it will be preserved on regeneration
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
diff --git a/Koha/Schema/Result/Deleteditem.pm b/Koha/Schema/Result/Deleteditem.pm
index f915511..a1d511c 100644
--- a/Koha/Schema/Result/Deleteditem.pm
+++ b/Koha/Schema/Result/Deleteditem.pm
@@ -383,6 +383,17 @@ __PACKAGE__->set_primary_key("itemnumber");
 # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-24 09:58:16
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ru5DyaIlWJcMNAgpZRjOLg
 
+__PACKAGE__->belongs_to(
+  "biblio",
+  "Koha::Schema::Result::Biblio",
+  { biblionumber => "biblionumber" }
+);
+
+__PACKAGE__->belongs_to(
+  "deleted_biblio",
+  "Koha::Schema::Result::Deletedbiblio",
+  { biblionumber => "biblionumber" }
+);
 
 # You can replace this text with custom content, and it will be preserved on regeneration
 1;
diff --git a/Koha/Schema/Result/Issue.pm b/Koha/Schema/Result/Issue.pm
index 5ec687e..46b6393 100644
--- a/Koha/Schema/Result/Issue.pm
+++ b/Koha/Schema/Result/Issue.pm
@@ -23,6 +23,12 @@ __PACKAGE__->table("issues");
 
 =head1 ACCESSORS
 
+=head2 issue_id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+
 =head2 borrowernumber
 
   data_type: 'integer'
@@ -104,6 +110,8 @@ __PACKAGE__->table("issues");
 =cut
 
 __PACKAGE__->add_columns(
+  "issue_id",
+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
   "borrowernumber",
   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
   "itemnumber",
@@ -153,6 +161,18 @@ __PACKAGE__->add_columns(
   { data_type => "integer", default_value => 0, is_nullable => 0 },
 );
 
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</issue_id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("issue_id");
+
 =head1 RELATIONS
 
 =head2 borrowernumber
@@ -200,10 +220,15 @@ __PACKAGE__->belongs_to(
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7Y+5IerDnajn5GLwAY5thg
 
 __PACKAGE__->belongs_to(
-    "borrower",
-    "Koha::Schema::Result::Borrower",
-    { borrowernumber => "borrowernumber" },
-    { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
+  "borrower",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "borrowernumber" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "RESTRICT",
+    on_update     => "CASCADE",
+  },
 );
 
 __PACKAGE__->belongs_to(
diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm
index 8ea22e3..9baa5ad 100644
--- a/Koha/Schema/Result/Item.pm
+++ b/Koha/Schema/Result/Item.pm
@@ -403,21 +403,6 @@ __PACKAGE__->add_unique_constraint("itembarcodeidx", ["barcode"]);
 
 =head1 RELATIONS
 
-=head2 accountlines
-
-Type: has_many
-
-Related object: L<Koha::Schema::Result::Accountline>
-
-=cut
-
-__PACKAGE__->has_many(
-  "accountlines",
-  "Koha::Schema::Result::Accountline",
-  { "foreign.itemnumber" => "self.itemnumber" },
-  { cascade_copy => 0, cascade_delete => 0 },
-);
-
 =head2 biblioitemnumber
 
 Type: belongs_to
diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm
index b56db99..aa78320 100644
--- a/Koha/Schema/Result/OldIssue.pm
+++ b/Koha/Schema/Result/OldIssue.pm
@@ -23,6 +23,12 @@ __PACKAGE__->table("old_issues");
 
 =head1 ACCESSORS
 
+=head2 issue_id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+
 =head2 borrowernumber
 
   data_type: 'integer'
@@ -104,6 +110,8 @@ __PACKAGE__->table("old_issues");
 =cut
 
 __PACKAGE__->add_columns(
+  "issue_id",
+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
   "borrowernumber",
   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
   "itemnumber",
@@ -153,6 +161,18 @@ __PACKAGE__->add_columns(
   { data_type => "integer", default_value => 0, is_nullable => 0 },
 );
 
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</issue_id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("issue_id");
+
 =head1 RELATIONS
 
 =head2 borrowernumber
@@ -199,6 +219,32 @@ __PACKAGE__->belongs_to(
 # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-11-03 10:40:55
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lNB9CDFcwG4DjD0pl14mvQ
 
+__PACKAGE__->belongs_to(
+  "borrower",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "borrowernumber" },
+  { join_type => "LEFT" },
+);
+
+__PACKAGE__->belongs_to(
+  "item",
+  "Koha::Schema::Result::Item",
+  { itemnumber => "itemnumber" },
+  { join_type => "LEFT" },
+);
+
+__PACKAGE__->belongs_to(
+  "deletedborrower",
+  "Koha::Schema::Result::Deletedborrower",
+  { borrowernumber => "borrowernumber" },
+  { join_type => "LEFT" },
+);
+
+__PACKAGE__->belongs_to(
+  "deleteditem",
+  "Koha::Schema::Result::Deleteditem",
+  { itemnumber => "itemnumber" },
+  { join_type => "LEFT" },
+);
 
-# You can replace this text with custom content, and it will be preserved on regeneration
 1;
-- 
1.7.2.5