Skip to content

Commit 8ada24c

Browse files
committed
[tasks] implement module
1 parent 708ce3c commit 8ada24c

19 files changed

Lines changed: 1998 additions & 8 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
go.uber.org/fx v1.24.0
2727
go.uber.org/zap v1.27.1
2828
golang.org/x/crypto v0.49.0
29+
golang.org/x/sync v0.20.0
2930
)
3031

3132
require (
@@ -91,7 +92,6 @@ require (
9192
go.yaml.in/yaml/v3 v3.0.4 // indirect
9293
golang.org/x/mod v0.33.0 // indirect
9394
golang.org/x/net v0.51.0 // indirect
94-
golang.org/x/sync v0.20.0 // indirect
9595
golang.org/x/sys v0.43.0 // indirect
9696
golang.org/x/text v0.35.0 // indirect
9797
golang.org/x/tools v0.42.0 // indirect

internal/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/bit-issues/backend/internal/jwt"
99
"github.com/bit-issues/backend/internal/projects"
1010
"github.com/bit-issues/backend/internal/server"
11+
"github.com/bit-issues/backend/internal/tasks"
1112
"github.com/bit-issues/backend/internal/users"
1213
"github.com/go-core-fx/bunfx"
1314
"github.com/go-core-fx/fiberfx"
@@ -52,6 +53,7 @@ func Run(version healthfx.Version) {
5253
jwt.Module(),
5354
users.Module(),
5455
projects.Module(),
56+
tasks.Module(),
5557
//
5658
fx.Invoke(func(lc fx.Lifecycle, logger *zap.Logger) {
5759
lc.Append(fx.Hook{
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
CREATE TABLE `tasks` (
4+
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
5+
`project_slug` VARCHAR(255) NOT NULL,
6+
`number` INT NOT NULL,
7+
`title` VARCHAR(255) NOT NULL,
8+
`description` TEXT,
9+
`priority` ENUM(
10+
'Trivial',
11+
'Minor',
12+
'Major',
13+
'Critical',
14+
'Blocker'
15+
) NOT NULL DEFAULT 'Minor',
16+
`status` ENUM(
17+
'New',
18+
'Open',
19+
'In Progress',
20+
'Resolved',
21+
'Closed',
22+
'Reopened'
23+
) NOT NULL DEFAULT 'New',
24+
`author_id` BIGINT UNSIGNED NOT NULL,
25+
`assignee_id` BIGINT UNSIGNED,
26+
`due_date` DATE,
27+
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
28+
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
29+
`deleted_at` DATETIME,
30+
PRIMARY KEY (`id`),
31+
UNIQUE KEY `idx_tasks_project_number` (`project_slug`, `number`),
32+
KEY `idx_tasks_author_id` (`author_id`),
33+
KEY `idx_tasks_assignee_id` (`assignee_id`),
34+
KEY `idx_tasks_status_priority` (`status`, `priority`),
35+
KEY `idx_tasks_created_at` (`created_at`),
36+
KEY `idx_tasks_due_date` (`due_date`),
37+
KEY `idx_tasks_deleted_at` (`deleted_at`),
38+
CONSTRAINT `fk_tasks_project` FOREIGN KEY (`project_slug`) REFERENCES `projects`(`id`) ON DELETE CASCADE,
39+
CONSTRAINT `fk_tasks_author` FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT,
40+
CONSTRAINT `fk_tasks_assignee` FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON DELETE
41+
SET NULL
42+
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
43+
-- +goose StatementEnd
44+
---
45+
-- +goose Down
46+
-- +goose StatementBegin
47+
DROP TABLE `tasks`;
48+
-- +goose StatementEnd

0 commit comments

Comments
 (0)