[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:14:27 CEST 2012
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7065
Galen Charlton <gmcharlt at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gmcharlt at gmail.com
--- Comment #13 from Galen Charlton <gmcharlt at gmail.com> ---
(In reply to comment #11)
> Would this be safer as an updatedatabase approach:
>
> alter table reserves add column reservenumber int(11) not null
> auto_increment primary key;
> set @ai=(select max(reservenumber) from reserves);
> alter table old_reserves add reservenumber int(11);
> insert into reserves select * from old_reserves;
> truncate old_reserves;
> insert into old_reserves select * from reserves where reservenumber > @ai;
> delete from reserves where reservenumber > @ai;
> alter table old_reserves add primary key reservenumber;
I suggest a variant of this approach so that old reserves have lower IDs than
current ones. Note that this is *untested*:
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 select * from old_reserves order by reservedate;
truncate old_reserves;
alter table old_reserves add reservenumber int(11);
insert into old_reserves select * from tmp_reserves);
truncate tmp_reserves;
insert into tmp_reserves select * 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);
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