You've already forked agentic-coding-workflow
feat(project): add workspace_id to issue/requirement with tri-state update
This commit is contained in:
@@ -22,14 +22,14 @@ func (q *Queries) CloseIssue(ctx context.Context, id pgtype.UUID) error {
|
||||
}
|
||||
|
||||
const createIssue = `-- name: CreateIssue :one
|
||||
INSERT INTO issues (id, project_id, requirement_id, number, title, description, assignee_id, created_by)
|
||||
INSERT INTO issues (id, project_id, requirement_id, number, title, description, assignee_id, created_by, workspace_id)
|
||||
VALUES (
|
||||
$1, $2, $3,
|
||||
(SELECT COALESCE(MAX(number), 0) + 1 FROM issues WHERE project_id = $2),
|
||||
$4, $5, $6, $7
|
||||
$4, $5, $6, $7, $8
|
||||
)
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
`
|
||||
|
||||
type CreateIssueParams struct {
|
||||
@@ -40,6 +40,7 @@ type CreateIssueParams struct {
|
||||
Description string `json:"description"`
|
||||
AssigneeID pgtype.UUID `json:"assignee_id"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue, error) {
|
||||
@@ -51,6 +52,7 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
|
||||
arg.Description,
|
||||
arg.AssigneeID,
|
||||
arg.CreatedBy,
|
||||
arg.WorkspaceID,
|
||||
)
|
||||
var i Issue
|
||||
err := row.Scan(
|
||||
@@ -66,13 +68,14 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getIssueByNumber = `-- name: GetIssueByNumber :one
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
FROM issues
|
||||
WHERE project_id = $1 AND number = $2
|
||||
`
|
||||
@@ -98,13 +101,14 @@ func (q *Queries) GetIssueByNumber(ctx context.Context, arg GetIssueByNumberPara
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listIssues = `-- name: ListIssues :many
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
FROM issues
|
||||
WHERE project_id = $1
|
||||
AND ($2::text IS NULL OR status = $2)
|
||||
@@ -153,6 +157,7 @@ func (q *Queries) ListIssues(ctx context.Context, arg ListIssuesParams) ([]Issue
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -166,7 +171,7 @@ func (q *Queries) ListIssues(ctx context.Context, arg ListIssuesParams) ([]Issue
|
||||
|
||||
const listIssuesByRequirement = `-- name: ListIssuesByRequirement :many
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
FROM issues
|
||||
WHERE requirement_id = $1
|
||||
ORDER BY number DESC
|
||||
@@ -194,6 +199,7 @@ func (q *Queries) ListIssuesByRequirement(ctx context.Context, requirementID pgt
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -220,7 +226,7 @@ UPDATE issues
|
||||
SET assignee_id = $2, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
`
|
||||
|
||||
type UpdateIssueAssigneeParams struct {
|
||||
@@ -244,6 +250,7 @@ func (q *Queries) UpdateIssueAssignee(ctx context.Context, arg UpdateIssueAssign
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -253,10 +260,11 @@ UPDATE issues
|
||||
SET title = $2,
|
||||
description = $3,
|
||||
requirement_id = $4,
|
||||
workspace_id = $5,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
`
|
||||
|
||||
type UpdateIssueCoreParams struct {
|
||||
@@ -264,6 +272,7 @@ type UpdateIssueCoreParams struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateIssueCore(ctx context.Context, arg UpdateIssueCoreParams) (Issue, error) {
|
||||
@@ -272,6 +281,7 @@ func (q *Queries) UpdateIssueCore(ctx context.Context, arg UpdateIssueCoreParams
|
||||
arg.Title,
|
||||
arg.Description,
|
||||
arg.RequirementID,
|
||||
arg.WorkspaceID,
|
||||
)
|
||||
var i Issue
|
||||
err := row.Scan(
|
||||
@@ -287,6 +297,7 @@ func (q *Queries) UpdateIssueCore(ctx context.Context, arg UpdateIssueCoreParams
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
@@ -21,6 +21,17 @@ type AuditLog struct {
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type GitCredential struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
Kind string `json:"kind"`
|
||||
Username *string `json:"username"`
|
||||
EncryptedSecret []byte `json:"encrypted_secret"`
|
||||
Fingerprint *string `json:"fingerprint"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Issue struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -34,6 +45,7 @@ type Issue struct {
|
||||
ClosedAt pgtype.Timestamptz `json:"closed_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
}
|
||||
|
||||
type Notification struct {
|
||||
@@ -73,6 +85,7 @@ type Requirement struct {
|
||||
ClosedAt pgtype.Timestamptz `json:"closed_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
@@ -93,3 +106,31 @@ type UserSession struct {
|
||||
LastSeenAt pgtype.Timestamptz `json:"last_seen_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type Workspace struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
Slug string `json:"slug"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
GitRemoteUrl string `json:"git_remote_url"`
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
MainPath string `json:"main_path"`
|
||||
SyncStatus string `json:"sync_status"`
|
||||
LastSyncedAt pgtype.Timestamptz `json:"last_synced_at"`
|
||||
LastSyncError *string `json:"last_sync_error"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type WorkspaceWorktree struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
Branch string `json:"branch"`
|
||||
Path string `json:"path"`
|
||||
Status string `json:"status"`
|
||||
ActiveHolder *string `json:"active_holder"`
|
||||
AcquiredAt pgtype.Timestamptz `json:"acquired_at"`
|
||||
LastUsedAt pgtype.Timestamptz `json:"last_used_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ func (q *Queries) CloseRequirement(ctx context.Context, id pgtype.UUID) error {
|
||||
}
|
||||
|
||||
const createRequirement = `-- name: CreateRequirement :one
|
||||
INSERT INTO requirements (id, project_id, number, title, description, owner_id)
|
||||
INSERT INTO requirements (id, project_id, number, title, description, owner_id, workspace_id)
|
||||
VALUES (
|
||||
$1, $2,
|
||||
(SELECT COALESCE(MAX(number), 0) + 1 FROM requirements WHERE project_id = $2),
|
||||
$3, $4, $5
|
||||
$3, $4, $5, $6
|
||||
)
|
||||
RETURNING id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
closed_at, created_at, updated_at, workspace_id
|
||||
`
|
||||
|
||||
type CreateRequirementParams struct {
|
||||
@@ -39,6 +39,7 @@ type CreateRequirementParams struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateRequirement(ctx context.Context, arg CreateRequirementParams) (Requirement, error) {
|
||||
@@ -48,6 +49,7 @@ func (q *Queries) CreateRequirement(ctx context.Context, arg CreateRequirementPa
|
||||
arg.Title,
|
||||
arg.Description,
|
||||
arg.OwnerID,
|
||||
arg.WorkspaceID,
|
||||
)
|
||||
var i Requirement
|
||||
err := row.Scan(
|
||||
@@ -62,13 +64,14 @@ func (q *Queries) CreateRequirement(ctx context.Context, arg CreateRequirementPa
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getRequirementByID = `-- name: GetRequirementByID :one
|
||||
SELECT id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
closed_at, created_at, updated_at, workspace_id
|
||||
FROM requirements WHERE id = $1
|
||||
`
|
||||
|
||||
@@ -87,13 +90,14 @@ func (q *Queries) GetRequirementByID(ctx context.Context, id pgtype.UUID) (Requi
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getRequirementByNumber = `-- name: GetRequirementByNumber :one
|
||||
SELECT id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
closed_at, created_at, updated_at, workspace_id
|
||||
FROM requirements
|
||||
WHERE project_id = $1 AND number = $2
|
||||
`
|
||||
@@ -118,13 +122,14 @@ func (q *Queries) GetRequirementByNumber(ctx context.Context, arg GetRequirement
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listRequirements = `-- name: ListRequirements :many
|
||||
SELECT id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
closed_at, created_at, updated_at, workspace_id
|
||||
FROM requirements
|
||||
WHERE project_id = $1
|
||||
AND ($2::text IS NULL OR phase = $2)
|
||||
@@ -159,6 +164,7 @@ func (q *Queries) ListRequirements(ctx context.Context, arg ListRequirementsPara
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -183,13 +189,14 @@ func (q *Queries) ReopenRequirement(ctx context.Context, id pgtype.UUID) error {
|
||||
|
||||
const updateRequirement = `-- name: UpdateRequirement :one
|
||||
UPDATE requirements
|
||||
SET title = $2,
|
||||
description = $3,
|
||||
owner_id = $4,
|
||||
updated_at = now()
|
||||
SET title = $2,
|
||||
description = $3,
|
||||
owner_id = $4,
|
||||
workspace_id = $5,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
closed_at, created_at, updated_at, workspace_id
|
||||
`
|
||||
|
||||
type UpdateRequirementParams struct {
|
||||
@@ -197,6 +204,7 @@ type UpdateRequirementParams struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateRequirement(ctx context.Context, arg UpdateRequirementParams) (Requirement, error) {
|
||||
@@ -205,6 +213,7 @@ func (q *Queries) UpdateRequirement(ctx context.Context, arg UpdateRequirementPa
|
||||
arg.Title,
|
||||
arg.Description,
|
||||
arg.OwnerID,
|
||||
arg.WorkspaceID,
|
||||
)
|
||||
var i Requirement
|
||||
err := row.Scan(
|
||||
@@ -219,6 +228,7 @@ func (q *Queries) UpdateRequirement(ctx context.Context, arg UpdateRequirementPa
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -228,7 +238,7 @@ UPDATE requirements
|
||||
SET phase = $2, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
closed_at, created_at, updated_at, workspace_id
|
||||
`
|
||||
|
||||
type UpdateRequirementPhaseParams struct {
|
||||
@@ -251,6 +261,7 @@ func (q *Queries) UpdateRequirementPhase(ctx context.Context, arg UpdateRequirem
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user