-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: updated default values in the database (#1596)
* feat: updated default values in the database * feat: added migration sql to update and revert default values
- Loading branch information
Showing
3 changed files
with
157 additions
and
27 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
-- ## Migration to: | ||
-- * Set default values to respective fields in the table. | ||
|
||
-- Start a transaction | ||
BEGIN; | ||
|
||
-- Update mapping_issue_categories table | ||
ALTER TABLE public.mapping_issue_categories | ||
ALTER COLUMN archived SET DEFAULT false; | ||
|
||
-- Update mbtiles_path table | ||
ALTER TABLE public.mbtiles_path | ||
ALTER COLUMN created_at SET DEFAULT now(); | ||
|
||
-- Update project_chat table | ||
ALTER TABLE public.project_chat | ||
ALTER COLUMN time_stamp SET DEFAULT now(); | ||
|
||
-- Update projects table | ||
ALTER TABLE public.projects | ||
ALTER COLUMN created SET DEFAULT now(), | ||
ALTER COLUMN last_updated SET DEFAULT now(), | ||
ALTER COLUMN status SET DEFAULT 'DRAFT', | ||
ALTER COLUMN mapper_level SET DEFAULT 'INTERMEDIATE', | ||
ALTER COLUMN priority SET DEFAULT 'MEDIUM', | ||
ALTER COLUMN featured SET DEFAULT false, | ||
ALTER COLUMN mapping_permission SET DEFAULT 'ANY', | ||
ALTER COLUMN validation_permission SET DEFAULT 'LEVEL'; | ||
|
||
-- Update task_history table | ||
ALTER TABLE public.task_history | ||
ALTER COLUMN action_date SET DEFAULT now(); | ||
|
||
-- Update task_invalidation_history table | ||
ALTER TABLE public.task_invalidation_history | ||
ALTER COLUMN is_closed SET DEFAULT false, | ||
ALTER COLUMN updated_date SET DEFAULT now(); | ||
|
||
-- Update tasks table | ||
ALTER TABLE public.tasks | ||
ALTER COLUMN task_status SET DEFAULT 'READY'; | ||
|
||
-- Update teams table | ||
ALTER TABLE public.teams | ||
ALTER COLUMN invite_only SET DEFAULT false, | ||
ALTER COLUMN visibility SET DEFAULT 'PUBLIC'; | ||
|
||
-- Update user_roles table | ||
ALTER TABLE public.user_roles | ||
ALTER COLUMN role SET DEFAULT 'MAPPER'; | ||
|
||
-- Update users table | ||
ALTER TABLE public.users | ||
ALTER COLUMN role SET DEFAULT 'MAPPER', | ||
ALTER COLUMN is_email_verified SET DEFAULT false, | ||
ALTER COLUMN is_expert SET DEFAULT false, | ||
ALTER COLUMN mapping_level SET DEFAULT 'BEGINNER', | ||
ALTER COLUMN tasks_mapped SET DEFAULT 0, | ||
ALTER COLUMN tasks_validated SET DEFAULT 0, | ||
ALTER COLUMN tasks_invalidated SET DEFAULT 0, | ||
ALTER COLUMN date_registered SET DEFAULT now(), | ||
ALTER COLUMN last_validation_date SET DEFAULT now(); | ||
|
||
-- Commit the transaction | ||
COMMIT; |
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
65 changes: 65 additions & 0 deletions
65
src/backend/migrations/revert/004-update-default-values.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,65 @@ | ||
-- ## Migration to: | ||
-- * Remove default values from respective fields in the table. | ||
|
||
-- Start a transaction | ||
BEGIN; | ||
|
||
-- Revert changes in mapping_issue_categories table | ||
ALTER TABLE public.mapping_issue_categories | ||
ALTER COLUMN archived DROP DEFAULT; | ||
|
||
-- Revert changes in mbtiles_path table | ||
ALTER TABLE public.mbtiles_path | ||
ALTER COLUMN created_at DROP DEFAULT; | ||
|
||
-- Revert changes in project_chat table | ||
ALTER TABLE public.project_chat | ||
ALTER COLUMN time_stamp DROP DEFAULT; | ||
|
||
-- Revert changes in projects table | ||
ALTER TABLE public.projects | ||
ALTER COLUMN created DROP DEFAULT, | ||
ALTER COLUMN last_updated DROP DEFAULT, | ||
ALTER COLUMN status DROP DEFAULT, | ||
ALTER COLUMN mapper_level DROP DEFAULT, | ||
ALTER COLUMN priority DROP DEFAULT, | ||
ALTER COLUMN featured DROP DEFAULT, | ||
ALTER COLUMN mapping_permission DROP DEFAULT, | ||
ALTER COLUMN validation_permission DROP DEFAULT; | ||
|
||
-- Revert changes in task_history table | ||
ALTER TABLE public.task_history | ||
ALTER COLUMN action_date DROP DEFAULT; | ||
|
||
-- Revert changes in task_invalidation_history table | ||
ALTER TABLE public.task_invalidation_history | ||
ALTER COLUMN is_closed DROP DEFAULT, | ||
ALTER COLUMN updated_date DROP DEFAULT; | ||
|
||
-- Revert changes in task_invalidation_history_id_seq table | ||
ALTER TABLE public.task_invalidation_history_id_seq | ||
ALTER COLUMN task_status DROP DEFAULT; | ||
|
||
-- Revert changes in teams table | ||
ALTER TABLE public.teams | ||
ALTER COLUMN invite_only DROP DEFAULT, | ||
ALTER COLUMN visibility DROP DEFAULT; | ||
|
||
-- Revert changes in user_roles table | ||
ALTER TABLE public.user_roles | ||
ALTER COLUMN role DROP DEFAULT; | ||
|
||
-- Revert changes in users table | ||
ALTER TABLE public.users | ||
ALTER COLUMN role DROP DEFAULT, | ||
ALTER COLUMN is_email_verified DROP DEFAULT, | ||
ALTER COLUMN is_expert DROP DEFAULT, | ||
ALTER COLUMN mapping_level DROP DEFAULT, | ||
ALTER COLUMN tasks_mapped DROP DEFAULT, | ||
ALTER COLUMN tasks_validated DROP DEFAULT, | ||
ALTER COLUMN tasks_invalidated DROP DEFAULT, | ||
ALTER COLUMN date_registered DROP DEFAULT, | ||
ALTER COLUMN last_validation_date DROP DEFAULT; | ||
|
||
-- Commit the transaction | ||
COMMIT; |