summaryrefslogtreecommitdiff
path: root/sql/Pg-upgrade-2.6.17-2.6.18.sql
blob: 4cf7c9e06714799247dfafd97f6866cbd29e46f7 (plain)
  1. -- linuxpoet:
  2. -- adding primary key to acc_trans
  3. -- We are using standard postgresql names for the sequence for consistency as we move forward
  4. -- Do everything in a transaction in case it blows up
  5. BEGIN;
  6. LOCK acc_trans in EXCLUSIVE mode;
  7. ALTER TABLE acc_trans ADD COLUMN entry_id bigint;
  8. CREATE SEQUENCE acctrans_entry_id_seq;
  9. ALTER TABLE acc_trans ALTER COLUMN entry_id SET DEFAULT nextval('acctrans_entry_id_seq');
  10. UPDATE acc_trans SET entry_id = nextval('acctrans_entry_id_seq');
  11. ALTER TABLE acc_trans ADD PRIMARY key (entry_id);
  12. -- The query rewrite rule necessary to notify the email app that a new report
  13. -- needs to be sent to the designated administrator.
  14. -- By Chris Travers
  15. -- chris@metatrontech.com
  16. -- Licensed under the GNU GPL 2.0 or later at your option. See accompanying
  17. -- GPL.txt
  18. CREATE OR REPLACE FUNCTION trigger_parts_short() RETURNS TRIGGER
  19. AS
  20. '
  21. BEGIN
  22. IF NEW.onhand >= NEW.rop THEN
  23. NOTIFY parts_short;
  24. END IF;
  25. RETURN NEW;
  26. END;
  27. ' LANGUAGE PLPGSQL;
  28. CREATE TRIGGER parts_short AFTER UPDATE ON parts
  29. FOR EACH ROW EXECUTE PROCEDURE trigger_parts_short();
  30. COMMIT;