arch: move web folder into api & move api to top level
This commit is contained in:
8
migrations/0001_add-refresh-token-table.up.sql
Normal file
8
migrations/0001_add-refresh-token-table.up.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
CREATE TABLE refresh_token (
|
||||
token_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
user_id uuid NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
expires_at timestamptz NOT NULL
|
||||
);
|
9
migrations/0002_add-user_account-table.up.sql
Normal file
9
migrations/0002_add-user_account-table.up.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE user_account (
|
||||
user_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
created_at timestamptz NOT NULL,
|
||||
first_name text NOT NULL,
|
||||
last_name text NOT NULL,
|
||||
email text NOT NULL UNIQUE,
|
||||
username text NOT NULL UNIQUE,
|
||||
password_hash text NOT NULL
|
||||
);
|
5
migrations/0003_add-team-table.up.sql
Normal file
5
migrations/0003_add-team-table.up.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE team (
|
||||
team_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
created_at timestamptz NOT NULL,
|
||||
name text NOT NULL
|
||||
);
|
6
migrations/0004_add-project-table.up.sql
Normal file
6
migrations/0004_add-project-table.up.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE project (
|
||||
project_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
team_id uuid NOT NULL REFERENCES team(team_id),
|
||||
created_at timestamptz NOT NULL,
|
||||
name text NOT NULL
|
||||
);
|
7
migrations/0005_add-task-group-table.up.sql
Normal file
7
migrations/0005_add-task-group-table.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE task_group (
|
||||
task_group_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
project_id uuid NOT NULL REFERENCES project(project_id),
|
||||
created_at timestamptz NOT NULL,
|
||||
name text NOT NULL,
|
||||
position float NOT NULL
|
||||
);
|
7
migrations/0006_add-task.up.sql
Normal file
7
migrations/0006_add-task.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE task (
|
||||
task_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
task_group_id uuid NOT NULL REFERENCES task_group(task_group_id),
|
||||
created_at timestamptz NOT NULL,
|
||||
name text NOT NULL,
|
||||
position float NOT NULL
|
||||
);
|
7
migrations/0007_add-organization-table.up.sql
Normal file
7
migrations/0007_add-organization-table.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE organization (
|
||||
organization_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
created_at timestamptz NOT NULL,
|
||||
name text NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO organization (created_at, name) VALUES (NOW(), 'sys_default_organization');
|
1
migrations/0008_add-org-id-to-team-table.up.sql
Normal file
1
migrations/0008_add-org-id-to-team-table.up.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE team ADD COLUMN organization_id uuid NOT NULL REFERENCES organization(organization_id);
|
6
migrations/0009_add-task-assigned-table.up.sql
Normal file
6
migrations/0009_add-task-assigned-table.up.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE task_assigned (
|
||||
task_assigned_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
task_id uuid NOT NULL REFERENCES task(task_id),
|
||||
user_id uuid NOT NULL REFERENCES user_account(user_id),
|
||||
assigned_date timestamptz NOT NULL
|
||||
);
|
1
migrations/0010_add-description-to-task-table.up.sql
Normal file
1
migrations/0010_add-description-to-task-table.up.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE task ADD COLUMN description text;
|
5
migrations/0011_add-label-color-table.up.sql
Normal file
5
migrations/0011_add-label-color-table.up.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE label_color (
|
||||
label_color_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
color_hex TEXT NOT NULL,
|
||||
position FLOAT NOT NULL
|
||||
);
|
7
migrations/0012_add-project-label-table.up.sql
Normal file
7
migrations/0012_add-project-label-table.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE project_label (
|
||||
project_label_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
project_id uuid NOT NULL REFERENCES project(project_id),
|
||||
label_color_id uuid NOT NULL REFERENCES label_color(label_color_id),
|
||||
created_date timestamptz NOT NULL,
|
||||
name text
|
||||
);
|
1
migrations/0013_add-due-date-to-task-table.up.sql
Normal file
1
migrations/0013_add-due-date-to-task-table.up.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE task ADD COLUMN due_date timestamptz;
|
1
migrations/0014_add-owner-column-to-project-table.up.sql
Normal file
1
migrations/0014_add-owner-column-to-project-table.up.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE project ADD COLUMN owner uuid NOT NULL;
|
6
migrations/0015_add-task-label-table.up.sql
Normal file
6
migrations/0015_add-task-label-table.up.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE task_label (
|
||||
task_label_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
task_id uuid NOT NULL REFERENCES task(task_id),
|
||||
project_label_id uuid NOT NULL REFERENCES project_label(project_label_id),
|
||||
assigned_date timestamptz NOT NULL
|
||||
);
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_account ADD COLUMN profile_bg_color text NOT NULL DEFAULT '#7367F0';
|
7
migrations/0017_add-profile-bg-delete-cascade.up.sql
Normal file
7
migrations/0017_add-profile-bg-delete-cascade.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
ALTER TABLE task_assigned
|
||||
DROP CONSTRAINT task_assigned_task_id_fkey,
|
||||
ADD CONSTRAINT task_assigned_task_id_fkey
|
||||
FOREIGN KEY (task_id)
|
||||
REFERENCES task(task_id)
|
||||
ON DELETE CASCADE;
|
||||
|
1
migrations/0018_add-name-column-to-label-color.up.sql
Normal file
1
migrations/0018_add-name-column-to-label-color.up.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE label_color ADD COLUMN name TEXT NOT NULL DEFAULT 'needs name';
|
@ -0,0 +1 @@
|
||||
ALTER TABLE task_label ADD UNIQUE (project_label_id, task_id);
|
@ -0,0 +1,3 @@
|
||||
ALTER TABLE user_account ADD COLUMN full_name TEXT;
|
||||
UPDATE user_account SET full_name = CONCAT(first_name, ' ', last_name);
|
||||
ALTER TABLE user_account ALTER COLUMN full_name SET NOT NULL;
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_account DROP COLUMN first_name;
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_account DROP COLUMN last_name;
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_account ADD COLUMN initials TEXT NOT NULL DEFAULT '';
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_account ADD COLUMN profile_avatar_url TEXT;
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE task_label DROP CONSTRAINT task_label_task_id_fkey;
|
||||
ALTER TABLE task_label
|
||||
ADD CONSTRAINT task_label_task_id_fkey
|
||||
FOREIGN KEY (task_id)
|
||||
REFERENCES task(task_id)
|
||||
ON DELETE CASCADE;
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE task_assigned DROP CONSTRAINT task_assigned_task_id_fkey;
|
||||
ALTER TABLE task_assigned
|
||||
ADD CONSTRAINT task_assigned_task_id_fkey
|
||||
FOREIGN KEY (task_id)
|
||||
REFERENCES task(task_id)
|
||||
ON DELETE CASCADE;
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE task DROP CONSTRAINT task_task_group_id_fkey;
|
||||
ALTER TABLE task
|
||||
ADD CONSTRAINT task_task_group_id_fkey
|
||||
FOREIGN KEY (task_group_id)
|
||||
REFERENCES task_group(task_group_id)
|
||||
ON DELETE CASCADE;
|
1
migrations/0028_add-complete-column-to-task-table.up.sql
Normal file
1
migrations/0028_add-complete-column-to-task-table.up.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE task ADD COLUMN complete boolean NOT NULL DEFAULT FALSE;
|
7
migrations/0029_add-task_checklist.up.sql
Normal file
7
migrations/0029_add-task_checklist.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE task_checklist (
|
||||
task_checklist_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
task_id uuid NOT NULL REFERENCES task(task_id) ON DELETE CASCADE,
|
||||
created_at timestamptz NOT NULL,
|
||||
name text NOT NULL,
|
||||
position float NOT NULL
|
||||
);
|
9
migrations/0030_add-task_checklist_item.up.sql
Normal file
9
migrations/0030_add-task_checklist_item.up.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE task_checklist_item (
|
||||
task_checklist_item_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
task_checklist_id uuid NOT NULL REFERENCES task_checklist(task_checklist_id) ON DELETE CASCADE,
|
||||
created_at timestamptz NOT NULL,
|
||||
complete boolean NOT NULL DEFAULT false,
|
||||
name text NOT NULL,
|
||||
position float NOT NULL,
|
||||
due_date timestamptz
|
||||
);
|
8
migrations/0031_add-team-member-table.up.sql
Normal file
8
migrations/0031_add-team-member-table.up.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE team_member (
|
||||
team_member_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
team_id uuid NOT NULL REFERENCES team(team_id) ON DELETE CASCADE,
|
||||
user_id uuid NOT NULL REFERENCES user_account(user_id) ON DELETE CASCADE,
|
||||
UNIQUE(team_id, user_id),
|
||||
addedDate timestamptz NOT NULL
|
||||
);
|
||||
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE project_label DROP CONSTRAINT project_label_project_id_fkey;
|
||||
ALTER TABLE project_label
|
||||
ADD CONSTRAINT project_label_project_id_fkey
|
||||
FOREIGN KEY (project_id)
|
||||
REFERENCES project(project_id)
|
||||
ON DELETE CASCADE;
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE task_label DROP CONSTRAINT task_label_project_label_id_fkey;
|
||||
ALTER TABLE task_label
|
||||
ADD CONSTRAINT task_label_project_label_id_fkey
|
||||
FOREIGN KEY (project_label_id)
|
||||
REFERENCES project_label(project_label_id)
|
||||
ON DELETE CASCADE;
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE project DROP CONSTRAINT project_team_id_fkey;
|
||||
ALTER TABLE project
|
||||
ADD CONSTRAINT project_team_id_fkey
|
||||
FOREIGN KEY (team_id)
|
||||
REFERENCES team(team_id)
|
||||
ON DELETE CASCADE;
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE task_assigned DROP CONSTRAINT task_assigned_user_id_fkey;
|
||||
ALTER TABLE task_assigned
|
||||
ADD CONSTRAINT task_assigned_user_id_fkey
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES user_account(user_id)
|
||||
ON DELETE CASCADE;
|
@ -0,0 +1,5 @@
|
||||
ALTER TABLE refresh_token
|
||||
ADD CONSTRAINT refresh_token_user_id_fkey
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES user_account(user_id)
|
||||
ON DELETE CASCADE;
|
6
migrations/0037_add-project_member-table.up.sql
Normal file
6
migrations/0037_add-project_member-table.up.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE project_member (
|
||||
project_member_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
project_id uuid NOT NULL REFERENCES project(project_id) ON DELETE CASCADE,
|
||||
user_id uuid NOT NULL REFERENCES user_account(user_id) ON DELETE CASCADE,
|
||||
added_at timestamptz NOT NULL
|
||||
);
|
9
migrations/0038_add-role-table.up.sql
Normal file
9
migrations/0038_add-role-table.up.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE role (
|
||||
code TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO role VALUES ('owner', 'Owner');
|
||||
INSERT INTO role VALUES ('admin', 'Admin');
|
||||
INSERT INTO role VALUES ('member', 'Member');
|
||||
INSERT INTO role VALUES ('observer', 'Observer');
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE user_account ADD COLUMN role_code text
|
||||
NOT NULL REFERENCES role(code) ON DELETE CASCADE DEFAULT 'member';
|
@ -0,0 +1 @@
|
||||
ALTER TABLE project_member ADD UNIQUE (project_id, user_id);
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE project_member ADD COLUMN role_code TEXT
|
||||
NOT NULL REFERENCES role(code) ON DELETE CASCADE DEFAULT 'member';
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_account ALTER COLUMN profile_avatar_url SET DEFAULT null;
|
@ -0,0 +1 @@
|
||||
ALTER TABLE team_member ADD COLUMN role_code TEXT NOT NULL REFERENCES role(code) ON DELETE CASCADE;
|
4
migrations/0044_add-owner-to-team-table.up.sql
Normal file
4
migrations/0044_add-owner-to-team-table.up.sql
Normal file
@ -0,0 +1,4 @@
|
||||
ALTER TABLE team ADD COLUMN owner uuid REFERENCES user_account(user_id) ON DELETE
|
||||
CASCADE;
|
||||
UPDATE team SET owner = (SELECT user_id FROM user_account WHERE role_code = 'admin' LIMIT 1);
|
||||
ALTER TABLE team ALTER COLUMN owner SET NOT NULL;
|
Reference in New Issue
Block a user