-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Backend API to delete user account #1661
- Loading branch information
1 parent
11d5430
commit 30978f0
Showing
3 changed files
with
107 additions
and
8 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
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,47 @@ | ||
-- ## Migration to: | ||
-- * Enable user data deletion | ||
|
||
-- Start a transaction | ||
BEGIN; | ||
|
||
-- Add column 'username' to 'task_events' table | ||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS ( | ||
SELECT 1 | ||
FROM information_schema.columns | ||
WHERE table_name='task_events' AND column_name='username' | ||
) THEN | ||
ALTER TABLE public.task_events | ||
ADD COLUMN username VARCHAR; | ||
END IF; | ||
END $$; | ||
|
||
-- Make 'user_id' nullable in 'task_events' table | ||
DO $$ | ||
BEGIN | ||
IF EXISTS ( | ||
SELECT 1 | ||
FROM information_schema.columns | ||
WHERE table_name='task_events' AND column_name='user_id' AND is_nullable = 'NO' | ||
) THEN | ||
ALTER TABLE public.task_events | ||
ALTER COLUMN user_id DROP NOT NULL; | ||
END IF; | ||
END $$; | ||
|
||
-- Make 'author_id' nullable in 'projects' table | ||
DO $$ | ||
BEGIN | ||
IF EXISTS ( | ||
SELECT 1 | ||
FROM information_schema.columns | ||
WHERE table_name='projects' AND column_name='author_id' AND is_nullable = 'NO' | ||
) THEN | ||
ALTER TABLE public.projects | ||
ALTER COLUMN author_id DROP NOT NULL; | ||
END IF; | ||
END $$; | ||
|
||
-- Commit the transaction | ||
COMMIT; |