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

(-)a/installer/data/mysql/kohastructure.sql (+4 lines)
Lines 1140-1145 CREATE TABLE `import_items` ( Link Here
1140
1140
1141
DROP TABLE IF EXISTS `issues`;
1141
DROP TABLE IF EXISTS `issues`;
1142
CREATE TABLE `issues` ( -- information related to check outs or issues
1142
CREATE TABLE `issues` ( -- information related to check outs or issues
1143
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1143
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1144
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1144
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1145
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1145
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1146
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
Lines 1152-1157 CREATE TABLE `issues` ( -- information related to check outs or issues Link Here
1152
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1153
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1153
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1154
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1154
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1155
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1156
  PRIMARY KEY (`issue_id`),
1155
  KEY `issuesborridx` (`borrowernumber`),
1157
  KEY `issuesborridx` (`borrowernumber`),
1156
  KEY `itemnumber_idx` (`itemnumber`),
1158
  KEY `itemnumber_idx` (`itemnumber`),
1157
  KEY `branchcode_idx` (`branchcode`),
1159
  KEY `branchcode_idx` (`branchcode`),
Lines 1614-1619 CREATE TABLE `oai_sets_biblios` ( Link Here
1614
1616
1615
DROP TABLE IF EXISTS `old_issues`;
1617
DROP TABLE IF EXISTS `old_issues`;
1616
CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1618
CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1619
  `issue_id` int(11) NOT NULL, -- primary key for issues table
1617
  `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1620
  `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1618
  `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1621
  `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1619
  `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
1622
  `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
Lines 1626-1631 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1626
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1629
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1627
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1630
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1628
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1631
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1632
  PRIMARY KEY (`issue_id`),
1629
  KEY `old_issuesborridx` (`borrowernumber`),
1633
  KEY `old_issuesborridx` (`borrowernumber`),
1630
  KEY `old_issuesitemidx` (`itemnumber`),
1634
  KEY `old_issuesitemidx` (`itemnumber`),
1631
  KEY `branchcode_idx` (`branchcode`),
1635
  KEY `branchcode_idx` (`branchcode`),
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +31 lines)
Lines 37-42 use Getopt::Long; Link Here
37
use C4::Context;
37
use C4::Context;
38
use C4::Installer;
38
use C4::Installer;
39
use C4::Dates;
39
use C4::Dates;
40
use Koha::Database;
40
41
41
use MARC::Record;
42
use MARC::Record;
42
use MARC::File::XML ( BinaryEncoding => 'utf8' );
43
use MARC::File::XML ( BinaryEncoding => 'utf8' );
Lines 3809-3816 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
3809
    print "Upgrade to $DBversion done (3.2.0 general release)\n";
3810
    print "Upgrade to $DBversion done (3.2.0 general release)\n";
3810
    SetVersion ($DBversion);
3811
    SetVersion ($DBversion);
3811
}
3812
}
3812
3813
# This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3813
# This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3814
3814
# apply updates that have already been done
3815
# apply updates that have already been done
3815
3816
3816
$DBversion = "3.03.00.001";
3817
$DBversion = "3.03.00.001";
Lines 9916-9921 if(CheckVersion($DBversion)) { Link Here
9916
    SetVersion($DBversion);
9917
    SetVersion($DBversion);
9917
}
9918
}
9918
9919
9920
9919
$DBversion = '3.19.00.017';
9921
$DBversion = '3.19.00.017';
9920
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
9922
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
9921
    # First create the column
9923
    # First create the column
Lines 10155-10160 while ( my $file = readdir $dirh ) { Link Here
10155
    my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
10157
    my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
10156
}
10158
}
10157
10159
10160
$DBversion = "XXX";
10161
if(CheckVersion($DBversion)) {
10162
    $dbh->do(q{
10163
        ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10164
    });
10165
10166
    $dbh->do(q{
10167
        ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10168
    });
10169
10170
    $dbh->do(q{
10171
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
10172
    });
10173
10174
    my $schema = Koha::Database->new()->schema();
10175
    my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max();
10176
    $max_issue_id ||= $schema->resultset('OldIssue')->get_column('issue_id')->max();
10177
    $max_issue_id ||= 0;
10178
    $max_issue_id++;
10179
    $dbh->do(qq{
10180
        ALTER TABLE issues AUTO_INCREMENT = $max_issue_id}
10181
    );
10182
10183
    print "Upgrade to $DBversion done (Bug 13790 - Add unique id issue_id to issues and oldissues tables)\n";
10184
    SetVersion($DBversion);
10185
10186
}
10187
10158
=head1 FUNCTIONS
10188
=head1 FUNCTIONS
10159
10189
10160
=head2 TableExists($table)
10190
=head2 TableExists($table)
10161
- 

Return to bug 13790