-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 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,30 @@ | ||
-- ## Migration to create task_comment table | ||
|
||
-- ## Apply Migration | ||
-- Start a transaction | ||
BEGIN; | ||
|
||
-- Create the 'task_comment' table if it doesn't exist | ||
CREATE TABLE IF NOT EXISTS public.task_comment ( | ||
id SERIAL PRIMARY KEY, | ||
task_id INT NOT NULL, | ||
project_id INT NOT NULL, | ||
comment_text TEXT NOT NULL, | ||
commented_by INT NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
|
||
-- Add foreign key constraint for task_id referencing a task table | ||
CONSTRAINT fk_task_id FOREIGN KEY (task_id, project_id) REFERENCES tasks(id, project_id), | ||
|
||
-- Add foreign key constraint for project_id referencing a project table | ||
CONSTRAINT fk_project_id FOREIGN KEY (project_id) REFERENCES projects(id), | ||
|
||
-- Add foreign key constraint for user_id referencing a user table | ||
CONSTRAINT fk_user_id FOREIGN KEY (commented_by) REFERENCES users(id) | ||
|
||
); | ||
ALTER TABLE public.task_comment OWNER TO fmtm; | ||
|
||
-- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
## Revert Migration (comment above, uncomment below) | ||
-- Start a transaction | ||
BEGIN; | ||
|
||
-- Drop the 'task_comment' table if it exists | ||
DROP TABLE IF EXISTS public.task_comment; | ||
|
||
-- Commit the transaction | ||
COMMIT; |