Creating a unique index on target_copy in the action.circulation table where
the checkin_time is NULL will increase the speed of circ transactions,
particularly on systems with a lot of traffic. The uniqueness also
ensures that a given item will not be able to be checked out multiple times
concurrently.
Thanks to James Fournie from BC Sitka for suggesting the index in Launchpad
bug 587031!
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16589
dcc99617-32d9-48b4-a31d-
7c20da2025e4
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0291'); -- dbs
+INSERT INTO config.upgrade_log (version) VALUES ('0292'); -- dbs
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
CREATE INDEX circ_circ_staff_idx ON action.circulation ( circ_staff );
CREATE INDEX circ_checkin_staff_idx ON action.circulation ( checkin_staff );
CREATE UNIQUE INDEX circ_parent_idx ON action.circulation ( parent_circ ) WHERE parent_circ IS NOT NULL;
-
+CREATE UNIQUE INDEX only_one_concurrent_checkout_per_copy ON action.circulation(target_copy) WHERE checkin_time IS NULL;
CREATE TRIGGER mat_summary_create_tgr AFTER INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_create ('circulation');
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
--- /dev/null
+BEGIN;
+INSERT INTO config.upgrade_log (version) VALUES ('0292'); -- dbs
+CREATE UNIQUE INDEX only_one_concurrent_checkout_per_copy ON action.circulation(target_copy) WHERE checkin_time IS NULL;
+COMMIT;