Skip to content

Commit

Permalink
Merge pull request #19 from turf-suite/feat/pm/task-schema
Browse files Browse the repository at this point in the history
Add Basic Tasks Schema
  • Loading branch information
Ryanaldo34 authored May 28, 2024
2 parents e5140e3 + 78576d3 commit d76954a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ create table if not exists

create table if not exists
public.profiles (
id uuid not null,
user_id uuid not null,
birthday date null,
first_name text null,
last_name text null,
middle_name text null default 'NULL'::text,
phone text null,
avatar text null,
organization uuid not null,
constraint profiles_pkey primary key (id),
constraint profiles_pkey primary key (user_id),
constraint profiles_phone_key unique (phone),
constraint profiles_organization_fkey foreign key (organization) references organizations (id) on delete cascade,
constraint profiles_id_fkey foreign key (id) references auth.users (id) on delete cascade
) tablespace pg_default;
constraint profiles_id_fkey foreign key (user_id) references auth.users (id) on delete cascade
) tablespace pg_default;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ create table if not exists public.team_members (
member_id uuid not null,
org_id uuid not null,
team_id serial not null,
constraint member_id_fkey foreign key (member_id) references public.profiles (id) on delete cascade,
constraint member_id_fkey foreign key (member_id) references public.profiles (user_id) on delete cascade,
constraint org_id_fkey foreign key (org_id) references public.organizations (id) on delete cascade,
constraint team_id_fkey foreign key (team_id) references public.teams (id) on delete cascade,
constraint team_members_pkey primary key (member_id, org_id, team_id)
Expand Down Expand Up @@ -43,7 +43,7 @@ create table if not exists public.kanban_projects (

create table if not exists public.agile_projects (
scrum_master uuid,
constraint scrum_master_fkey foreign key (scrum_master) references public.profiles (id),
constraint scrum_master_fkey foreign key (scrum_master) references public.profiles (user_id),
constraint agile_projects_fkey foreign key (id) references public.projects (id) on delete cascade
) inherits (public.projects) tablespace pg_default;

Expand Down
31 changes: 15 additions & 16 deletions libs/supabase/supabase/migrations/20240406045443_boards_schema.sql
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 libs/supabase/supabase/migrations/20240521004036_tasks_schema.sql
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;

0 comments on commit d76954a

Please sign in to comment.