[Koha-bugs] [Bug 7065] reserves table needs a primary key

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu May 3 16:31:24 CEST 2012


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7065

--- Comment #14 from Galen Charlton <gmcharlt at gmail.com> ---
And a more tested version:

create table tmp_reserves as select * from reserves limit 0;
alter table tmp_reserves add column reservenumber int(11) not null
auto_increment primary key;
insert into tmp_reserves (borrowernumber, reservedate, biblionumber,
constrainttype, branchcode, notificationdate, reminderdate, cancellationdate,
reservenotes, priority, found, timestamp, itemnumber, waitingdate,
expirationdate, lowestPriority) select borrowernumber, reservedate,
biblionumber, constrainttype, branchcode, notificationdate, reminderdate,
cancellationdate, reservenotes, priority, found, timestamp, itemnumber,
waitingdate, expirationdate, lowestPriority from old_reserves order by
reservedate;

set @ai=(select max(reservenumber) from tmp_reserves);

truncate old_reserves;
alter table old_reserves add reservenumber int(11);
insert into old_reserves select * from tmp_reserves where reservenumber <= @ai;

insert into tmp_reserves (borrowernumber, reservedate, biblionumber,
constrainttype, branchcode, notificationdate, reminderdate, cancellationdate,
reservenotes, priority, found, timestamp, itemnumber, waitingdate,
expirationdate, lowestPriority) select borrowernumber, reservedate,
biblionumber, constrainttype, branchcode, notificationdate, reminderdate,
cancellationdate, reservenotes, priority, found, timestamp, itemnumber,
waitingdate, expirationdate, lowestPriority from reserves order by reservedate;

alter table reserves add reservenumber int(11) not null auto_increment
primary_key;
truncate reserves;
insert into reserves select * from tmp_reserves where reservenumber > @ai;
drop table tmp_reserves;

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list