-
Notifications
You must be signed in to change notification settings - Fork 0
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 #19 from turf-suite/feat/pm/task-schema
Add Basic Tasks Schema
- Loading branch information
Showing
4 changed files
with
89 additions
and
22 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
31 changes: 15 additions & 16 deletions
31
libs/supabase/supabase/migrations/20240406045443_boards_schema.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 |
---|---|---|
@@ -1,32 +1,31 @@ | ||
create table if not exists public.boards ( | ||
id bigserial, | ||
board_name text not null, | ||
project_id serial not null, | ||
team_id serial not null, | ||
constraint boards_pkey primary key (id), | ||
constraint boards_pkey primary key (project_id, board_name), | ||
constraint projects_fkey foreign key (project_id) references public.projects (id) on delete cascade, | ||
constraint team_fkey foreign key (team_id) references public.teams (id) on delete cascade | ||
) tablespace pg_default; | ||
|
||
create table if not exists public.board_states ( | ||
id bigserial, | ||
board_id bigserial not null, | ||
board_name text, | ||
project_id serial, | ||
name text not null, | ||
ordering smallint not null, | ||
is_completion_state boolean not null, | ||
is_cancelled_state boolean not null, | ||
constraint board_fkey foreign key (board_id) references public.boards (id) on delete cascade, | ||
constraint board_states_pkey primary key (id), | ||
constraint unique_name unique (board_id, name) | ||
constraint board_fkey foreign key (board_name, project_id) references public.boards (board_name, project_id) on delete cascade, | ||
constraint board_states_pkey primary key (name, board_name, project_id) | ||
) tablespace pg_default; | ||
|
||
create table if not exists public.board_task_state_transitions ( | ||
board_id bigserial not null, | ||
from_state_id bigserial not null, | ||
to_state_id bigserial not null, | ||
constraint task_state_transitions_pkey primary key (board_id, from_state_id, to_state_id), | ||
constraint board_fkey foreign key (board_id) references public.boards (id), | ||
constraint from_fkey foreign key (from_state_id) references public.board_states (id), | ||
constraint to_fkey foreign key (to_state_id) references public.board_states (id), | ||
constraint different_states check (from_state_id <> to_state_id), | ||
constraint unique_transition unique (from_state_id, to_state_id) | ||
board_name text, | ||
project_id serial, | ||
to_state_name text, | ||
from_state_name text, | ||
constraint task_state_transitions_pkey primary key (board_name, project_id, from_state_name, to_state_name), | ||
constraint from_fkey foreign key (board_name, project_id, from_state_name) references public.board_states (board_name, project_id, name), | ||
constraint to_fkey foreign key (board_name, project_id, to_state_name) references public.board_states (board_name, project_id, name), | ||
constraint different_states check (from_state_name <> to_state_name), | ||
constraint unique_transition unique(board_name, project_id, to_state_name, from_state_name) | ||
) tablespace pg_default; |
68 changes: 68 additions & 0 deletions
68
libs/supabase/supabase/migrations/20240521004036_tasks_schema.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,68 @@ | ||
create table public.tasks ( | ||
task_id numeric, | ||
project_id serial, | ||
board_name text, | ||
task_title text, | ||
task_description text, | ||
assignee uuid, | ||
reviewer uuid, | ||
due_date date, | ||
hours_estimated integer, | ||
hours_completed integer, | ||
constraint tasks_pkey primary key (task_id, project_id, board_name), | ||
constraint board_fkey foreign key (board_name, project_id) | ||
references public.boards (board_name, project_id) on delete cascade, | ||
constraint assignee_fkey foreign key (assignee) | ||
references public.profiles (user_id), | ||
constraint reviewer_fkey foreign key (reviewer) | ||
references public.profiles (user_id) | ||
) tablespace pg_default; | ||
|
||
create table public.parent_child_tasks ( | ||
parent_task_project_id serial, | ||
parent_task_board_name text, | ||
parent_task_id numeric, | ||
child_task_project_id serial, | ||
child_task_board_name text, | ||
child_task_id numeric, | ||
constraint parent_task_fkey foreign key (parent_task_id, parent_task_board_name, parent_task_project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade, | ||
constraint child_task_fkey foreign key (child_task_id, child_task_board_name, child_task_project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade, | ||
constraint only_one_parent unique (child_task_project_id, child_task_board_name, child_task_id) | ||
) tablespace pg_default; | ||
|
||
create table public.related_tasks ( | ||
linked_task_project_id serial, | ||
linked_task_board_name text, | ||
linked_task_id numeric, | ||
task_id numeric, | ||
task_project_id serial, | ||
task_board_name text, | ||
constraint task_fkey foreign key (task_id, task_board_name, task_project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade, | ||
constraint linked_task_fkey foreign key (linked_task_id, linked_task_board_name, linked_task_project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade | ||
) tablespace pg_default; | ||
|
||
create table public.blocker_tasks ( | ||
blocker_task_project_id serial, | ||
blocker_task_board_name text, | ||
blocker_task_id numeric, | ||
task_id numeric, | ||
task_project_id serial, | ||
task_board_name text, | ||
constraint task_fkey foreign key (task_id, task_board_name, task_project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade, | ||
constraint blocker_task_fkey foreign key (blocker_task_id, blocker_task_board_name, blocker_task_project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade | ||
) tablespace pg_default; | ||
|
||
create table public.task_tags ( | ||
tag_name text not null, | ||
task_id numeric not null, | ||
board_name text not null, | ||
project_id serial not null, | ||
constraint task_fkey foreign key (task_id, board_name, project_id) | ||
references public.tasks (task_id, board_name, project_id) on delete cascade | ||
) tablespace pg_default; |