mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-18 07:39:29 +02:00
Moving an issue renumbers it in the destination team (numbers are per-team) inside one tx: allocate the next counter value, take a fresh top position, and record the pre-move identifier in the new issue_identifier_alias table. Both identifier resolution points (the shared loadIssueForUser path and GitHub branch/PR auto-linking) fall back to the alias, so old identifiers keep resolving forever; numbers are never reused, so aliases can't shadow live issues. Associations now bind at creation time only: drop the cross-team parent/child checks, the explicit team x project association check in ResolveTeam, the project-change team validation in UpdateIssue, and the still-has-issues 409 when removing a team from a project. The broadcast gains team_changed/prev_team_id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
85 lines
2.4 KiB
Go
85 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: issue_identifier_alias.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const getIssueByIdentifierAlias = `-- name: GetIssueByIdentifierAlias :one
|
|
SELECT i.id, i.workspace_id, i.title, i.description, i.status, i.priority, i.assignee_type, i.assignee_id, i.creator_type, i.creator_id, i.parent_issue_id, i.acceptance_criteria, i.context_refs, i.position, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.origin_type, i.origin_id, i.first_executed_at, i.start_date, i.metadata, i.stage, i.team_id FROM issue_identifier_alias a
|
|
JOIN issue i ON i.id = a.issue_id
|
|
WHERE a.workspace_id = $1
|
|
AND a.team_key_lower = $2
|
|
AND a.number = $3
|
|
`
|
|
|
|
type GetIssueByIdentifierAliasParams struct {
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
TeamKeyLower string `json:"team_key_lower"`
|
|
Number int32 `json:"number"`
|
|
}
|
|
|
|
func (q *Queries) GetIssueByIdentifierAlias(ctx context.Context, arg GetIssueByIdentifierAliasParams) (Issue, error) {
|
|
row := q.db.QueryRow(ctx, getIssueByIdentifierAlias, arg.WorkspaceID, arg.TeamKeyLower, arg.Number)
|
|
var i Issue
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Status,
|
|
&i.Priority,
|
|
&i.AssigneeType,
|
|
&i.AssigneeID,
|
|
&i.CreatorType,
|
|
&i.CreatorID,
|
|
&i.ParentIssueID,
|
|
&i.AcceptanceCriteria,
|
|
&i.ContextRefs,
|
|
&i.Position,
|
|
&i.DueDate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Number,
|
|
&i.ProjectID,
|
|
&i.OriginType,
|
|
&i.OriginID,
|
|
&i.FirstExecutedAt,
|
|
&i.StartDate,
|
|
&i.Metadata,
|
|
&i.Stage,
|
|
&i.TeamID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const upsertIssueIdentifierAlias = `-- name: UpsertIssueIdentifierAlias :exec
|
|
INSERT INTO issue_identifier_alias (workspace_id, team_key_lower, number, issue_id)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (workspace_id, team_key_lower, number)
|
|
DO UPDATE SET issue_id = EXCLUDED.issue_id
|
|
`
|
|
|
|
type UpsertIssueIdentifierAliasParams struct {
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
TeamKeyLower string `json:"team_key_lower"`
|
|
Number int32 `json:"number"`
|
|
IssueID pgtype.UUID `json:"issue_id"`
|
|
}
|
|
|
|
func (q *Queries) UpsertIssueIdentifierAlias(ctx context.Context, arg UpsertIssueIdentifierAliasParams) error {
|
|
_, err := q.db.Exec(ctx, upsertIssueIdentifierAlias,
|
|
arg.WorkspaceID,
|
|
arg.TeamKeyLower,
|
|
arg.Number,
|
|
arg.IssueID,
|
|
)
|
|
return err
|
|
}
|