ALTER TABLE asset.stat_cat
ADD COLUMN checkout_archive BOOL NOT NULL DEFAULT FALSE;
+-- Speed up the upgrade process prevening the four UPDATE triggers from firing
+ALTER TABLE action.circulation DISABLE TRIGGER ALL;
+
-- Circulation copy column
ALTER TABLE action.circulation
ADD COLUMN copy_location INT NOT NULL DEFAULT 1 REFERENCES asset.copy_location(id) DEFERRABLE INITIALLY DEFERRED;
-- Update action.circulation with real copy_location numbers instead of all "Stacks"
UPDATE action.circulation circ SET copy_location = ac.location FROM asset.copy ac WHERE ac.id = circ.target_copy;
+-- Re-enable the triggers now that the upgrade of the table is complete
+ALTER TABLE action.circulation ENABLE TRIGGER ALL;
+
-- Create trigger function to auto-fill the copy_location field
CREATE OR REPLACE FUNCTION action.fill_circ_copy_location () RETURNS TRIGGER AS $$
BEGIN