This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds work_item_type_id to existing tracker_queries; Adds tests;
- Loading branch information
1 parent
936cfc9
commit 68498a6
Showing
2 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
ALTER TABLE tracker_queries ADD COLUMN work_item_type_id uuid REFERENCES work_item_types(id); | ||
CREATE OR REPLACE FUNCTION adds_wit() RETURNS void as $$ | ||
-- adds_wit() function adds work_item_type to existing tracker_queries in database | ||
This comment has been minimized.
Sorry, something went wrong.
kwk
Collaborator
|
||
DECLARE | ||
r RECORD; | ||
c CURSOR FOR SELECT id, space_id, work_item_type_id from tracker_queries; | ||
BEGIN | ||
open c; | ||
FOR r in FETCH ALL FROM c LOOP | ||
UPDATE tracker_queries as tq | ||
SET work_item_type_id = wit.id | ||
FROM work_item_types as wit, spaces as sp | ||
WHERE | ||
tq.space_id = sp.id | ||
AND sp.space_template_id = wit.space_template_id | ||
AND wit.can_construct = true; | ||
END LOOP; | ||
close c; | ||
END $$ LANGUAGE plpgsql; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE tracker_queries ADD COLUMN work_item_type_id uuid REFERENCES work_item_types(id) ON DELETE CASCADE; | ||
PERFORM adds_wit(); | ||
DROP FUNCTION adds_wit(); | ||
ALTER TABLE tracker_queries ALTER COLUMN work_item_type_id set not null; | ||
END $$; | ||
|
Why not simply use
dialect.Has...
instead?