mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:37:08 +00:00
34 lines
1003 B
MySQL
34 lines
1003 B
MySQL
|
|
-- Upgrade the database from commit 3d70a460 to 0983abac.
|
||
|
|
--
|
||
|
|
-- NOTE: This upgrade must be applied to every schema in the database.
|
||
|
|
-- NOTE: Each application starts a transaction, which must be committed
|
||
|
|
-- or rolled back.
|
||
|
|
--
|
||
|
|
-- This:
|
||
|
|
--
|
||
|
|
-- * makes the primary key on planned_lines deferrable; and
|
||
|
|
-- * changes the planned_lines trigger from statement to row.
|
||
|
|
--
|
||
|
|
-- To apply, run as the dougal user, for every schema in the database:
|
||
|
|
--
|
||
|
|
-- psql <<EOF
|
||
|
|
-- SET search_path TO survey_*,public;
|
||
|
|
-- \i $THIS_FILE
|
||
|
|
-- COMMIT;
|
||
|
|
-- EOF
|
||
|
|
--
|
||
|
|
-- NOTE: It can be applied multiple times without ill effect.
|
||
|
|
|
||
|
|
|
||
|
|
BEGIN;
|
||
|
|
|
||
|
|
ALTER TABLE planned_lines DROP CONSTRAINT planned_lines_pkey;
|
||
|
|
ALTER TABLE planned_lines ADD CONSTRAINT planned_lines_pkey PRIMARY KEY (sequence) DEFERRABLE;
|
||
|
|
|
||
|
|
DROP TRIGGER planned_lines_tg ON planned_lines;
|
||
|
|
CREATE TRIGGER planned_lines_tg AFTER INSERT OR DELETE OR UPDATE ON planned_lines FOR EACH ROW EXECUTE FUNCTION public.notify('planned_lines');
|
||
|
|
|
||
|
|
--
|
||
|
|
--NOTE Run `COMMIT;` now if all went well
|
||
|
|
--
|