-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split up sql file for better readability
- Loading branch information
1 parent
24d783b
commit a128711
Showing
2 changed files
with
60 additions
and
60 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
51 changes: 51 additions & 0 deletions
51
backend/src/main/resources/db/migration/V3_5_0__recreateOverview.sql
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
DO | ||
$$ | ||
BEGIN | ||
IF EXISTS(SELECT * | ||
FROM information_schema.columns | ||
WHERE table_name = 'key_result' | ||
and column_name = 'unit') | ||
THEN | ||
DROP VIEW IF EXISTS OVERVIEW; | ||
CREATE VIEW OVERVIEW AS | ||
SELECT tq.team_id AS "team_id", | ||
tq.team_version AS "team_version", | ||
tq.name AS "team_name", | ||
tq.quater_id AS "quarter_id", | ||
tq.label AS "quarter_label", | ||
coalesce(o.id, -1) AS "objective_id", | ||
o.title AS "objective_title", | ||
o.state AS "objective_state", | ||
o.created_on AS "objective_created_on", | ||
coalesce(kr.id, -1) AS "key_result_id", | ||
kr.title AS "key_result_title", | ||
kr.key_result_type AS "key_result_type", | ||
U.unit_name as "unit", | ||
kr.baseline, | ||
kr.stretch_goal, | ||
kr.commit_zone, | ||
kr.target_zone, | ||
kr.stretch_zone, | ||
coalesce(c.id, -1) AS "check_in_id", | ||
c.value_metric AS "check_in_value", | ||
c.zone AS "check_in_zone", | ||
c.confidence, | ||
c.created_on AS "check_in_created_on" | ||
FROM (select t.id as team_id, t.version as team_version, t.name, q.id as quater_id, q.label | ||
from team t, | ||
quarter q) tq | ||
LEFT JOIN OBJECTIVE O ON TQ.TEAM_ID = O.TEAM_ID AND TQ.QUATER_ID = O.QUARTER_ID | ||
LEFT JOIN KEY_RESULT KR ON O.ID = KR.OBJECTIVE_ID | ||
LEFT JOIN unit U ON U.ID = KR.unit_id | ||
LEFT JOIN CHECK_IN C ON KR.ID = C.KEY_RESULT_ID AND C.MODIFIED_ON = (SELECT MAX(CC.MODIFIED_ON) | ||
FROM CHECK_IN CC | ||
WHERE CC.KEY_RESULT_ID = C.KEY_RESULT_ID); | ||
|
||
alter table key_result | ||
drop column if exists unit cascade ; | ||
|
||
|
||
END IF; | ||
END | ||
$$; | ||
|