You've already forked agentic-coding-workflow
265 lines
6.7 KiB
Go
265 lines
6.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: workspaces.sql
|
|
|
|
package workspacesqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createWorkspace = `-- name: CreateWorkspace :one
|
|
INSERT INTO workspaces (
|
|
id, project_id, slug, name, description,
|
|
git_remote_url, default_branch, main_path, sync_status
|
|
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)
|
|
RETURNING id, project_id, slug, name, description, git_remote_url, default_branch, main_path, sync_status, last_synced_at, last_sync_error, created_at, updated_at
|
|
`
|
|
|
|
type CreateWorkspaceParams 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"`
|
|
}
|
|
|
|
func (q *Queries) CreateWorkspace(ctx context.Context, arg CreateWorkspaceParams) (Workspace, error) {
|
|
row := q.db.QueryRow(ctx, createWorkspace,
|
|
arg.ID,
|
|
arg.ProjectID,
|
|
arg.Slug,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.GitRemoteUrl,
|
|
arg.DefaultBranch,
|
|
arg.MainPath,
|
|
arg.SyncStatus,
|
|
)
|
|
var i Workspace
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.GitRemoteUrl,
|
|
&i.DefaultBranch,
|
|
&i.MainPath,
|
|
&i.SyncStatus,
|
|
&i.LastSyncedAt,
|
|
&i.LastSyncError,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteWorkspace = `-- name: DeleteWorkspace :exec
|
|
DELETE FROM workspaces WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteWorkspace(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteWorkspace, id)
|
|
return err
|
|
}
|
|
|
|
const getWorkspaceByID = `-- name: GetWorkspaceByID :one
|
|
SELECT id, project_id, slug, name, description, git_remote_url, default_branch, main_path, sync_status, last_synced_at, last_sync_error, created_at, updated_at FROM workspaces WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetWorkspaceByID(ctx context.Context, id pgtype.UUID) (Workspace, error) {
|
|
row := q.db.QueryRow(ctx, getWorkspaceByID, id)
|
|
var i Workspace
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.GitRemoteUrl,
|
|
&i.DefaultBranch,
|
|
&i.MainPath,
|
|
&i.SyncStatus,
|
|
&i.LastSyncedAt,
|
|
&i.LastSyncError,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getWorkspaceBySlug = `-- name: GetWorkspaceBySlug :one
|
|
SELECT w.id, w.project_id, w.slug, w.name, w.description, w.git_remote_url, w.default_branch, w.main_path, w.sync_status, w.last_synced_at, w.last_sync_error, w.created_at, w.updated_at FROM workspaces w
|
|
JOIN projects p ON p.id = w.project_id
|
|
WHERE p.slug = $1 AND w.slug = $2
|
|
`
|
|
|
|
type GetWorkspaceBySlugParams struct {
|
|
Slug string `json:"slug"`
|
|
Slug_2 string `json:"slug_2"`
|
|
}
|
|
|
|
func (q *Queries) GetWorkspaceBySlug(ctx context.Context, arg GetWorkspaceBySlugParams) (Workspace, error) {
|
|
row := q.db.QueryRow(ctx, getWorkspaceBySlug, arg.Slug, arg.Slug_2)
|
|
var i Workspace
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.GitRemoteUrl,
|
|
&i.DefaultBranch,
|
|
&i.MainPath,
|
|
&i.SyncStatus,
|
|
&i.LastSyncedAt,
|
|
&i.LastSyncError,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listWorkspacesByProject = `-- name: ListWorkspacesByProject :many
|
|
SELECT id, project_id, slug, name, description, git_remote_url, default_branch, main_path, sync_status, last_synced_at, last_sync_error, created_at, updated_at FROM workspaces WHERE project_id = $1
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListWorkspacesByProject(ctx context.Context, projectID pgtype.UUID) ([]Workspace, error) {
|
|
rows, err := q.db.Query(ctx, listWorkspacesByProject, projectID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Workspace
|
|
for rows.Next() {
|
|
var i Workspace
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.GitRemoteUrl,
|
|
&i.DefaultBranch,
|
|
&i.MainPath,
|
|
&i.SyncStatus,
|
|
&i.LastSyncedAt,
|
|
&i.LastSyncError,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const resetStuckSyncStatuses = `-- name: ResetStuckSyncStatuses :exec
|
|
UPDATE workspaces
|
|
SET sync_status = 'error',
|
|
last_sync_error = 'process_restarted_during_' || sync_status,
|
|
updated_at = now()
|
|
WHERE sync_status IN ('cloning', 'syncing')
|
|
`
|
|
|
|
func (q *Queries) ResetStuckSyncStatuses(ctx context.Context) error {
|
|
_, err := q.db.Exec(ctx, resetStuckSyncStatuses)
|
|
return err
|
|
}
|
|
|
|
const updateWorkspaceCore = `-- name: UpdateWorkspaceCore :one
|
|
UPDATE workspaces
|
|
SET name = $2, description = $3, default_branch = $4, updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, project_id, slug, name, description, git_remote_url, default_branch, main_path, sync_status, last_synced_at, last_sync_error, created_at, updated_at
|
|
`
|
|
|
|
type UpdateWorkspaceCoreParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
DefaultBranch string `json:"default_branch"`
|
|
}
|
|
|
|
func (q *Queries) UpdateWorkspaceCore(ctx context.Context, arg UpdateWorkspaceCoreParams) (Workspace, error) {
|
|
row := q.db.QueryRow(ctx, updateWorkspaceCore,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.DefaultBranch,
|
|
)
|
|
var i Workspace
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.GitRemoteUrl,
|
|
&i.DefaultBranch,
|
|
&i.MainPath,
|
|
&i.SyncStatus,
|
|
&i.LastSyncedAt,
|
|
&i.LastSyncError,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateWorkspaceSyncStatus = `-- name: UpdateWorkspaceSyncStatus :one
|
|
UPDATE workspaces
|
|
SET sync_status = $2,
|
|
last_synced_at = $3,
|
|
last_sync_error = $4,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, project_id, slug, name, description, git_remote_url, default_branch, main_path, sync_status, last_synced_at, last_sync_error, created_at, updated_at
|
|
`
|
|
|
|
type UpdateWorkspaceSyncStatusParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
SyncStatus string `json:"sync_status"`
|
|
LastSyncedAt pgtype.Timestamptz `json:"last_synced_at"`
|
|
LastSyncError *string `json:"last_sync_error"`
|
|
}
|
|
|
|
func (q *Queries) UpdateWorkspaceSyncStatus(ctx context.Context, arg UpdateWorkspaceSyncStatusParams) (Workspace, error) {
|
|
row := q.db.QueryRow(ctx, updateWorkspaceSyncStatus,
|
|
arg.ID,
|
|
arg.SyncStatus,
|
|
arg.LastSyncedAt,
|
|
arg.LastSyncError,
|
|
)
|
|
var i Workspace
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.GitRemoteUrl,
|
|
&i.DefaultBranch,
|
|
&i.MainPath,
|
|
&i.SyncStatus,
|
|
&i.LastSyncedAt,
|
|
&i.LastSyncError,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|