-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from Tampere/feature/refactor-project-types
Refactor project types and search
- Loading branch information
Showing
50 changed files
with
1,375 additions
and
951 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[sqlfluff] | ||
exclude_rules = L031 | ||
dialect = postgres | ||
|
||
[sqlfluff:rules] | ||
tab_space_size = 2 | ||
|
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ALTER TABLE project_common RENAME TO project_investment; | ||
ALTER TABLE project_investment DROP COLUMN project_type; | ||
|
||
-- Add new columns as optional | ||
ALTER TABLE project | ||
ADD COLUMN start_date date, | ||
ADD COLUMN end_date date, | ||
ADD COLUMN lifecycle_state code_id; | ||
|
||
-- Set default values | ||
UPDATE project | ||
SET start_date = current_date, | ||
end_date = current_date, | ||
lifecycle_state = ('HankkeenElinkaarentila', '01')::code_id; | ||
|
||
-- Override with existing values if found | ||
UPDATE project p | ||
SET start_date = pi.start_date, | ||
end_date = pi.end_date, | ||
lifecycle_state = pi.lifecycle_state | ||
FROM project_investment AS pi | ||
WHERE p.id = pi.id; | ||
|
||
-- Set the columns required | ||
ALTER TABLE project | ||
ALTER COLUMN start_date | ||
SET NOT NULL, | ||
ALTER COLUMN end_date | ||
SET NOT NULL, | ||
ALTER COLUMN lifecycle_state | ||
SET NOT NULL; | ||
|
||
-- Remove the old columns | ||
ALTER TABLE project_investment DROP COLUMN start_date, | ||
DROP COLUMN end_date, | ||
DROP COLUMN lifecycle_state; | ||
|
||
-- Remove old project type code list | ||
DELETE FROM code WHERE (id) .code_list_id = 'HankeTyyppi'; |
Oops, something went wrong.