chore(db): remove 23 unused database methods (#22999)

Removes 22 database query methods with no callers outside generated code
and the dbauthz wrapper layer (~1,600 lines).

**Security keys (6)** — superseded by `cryptokeys` package:
`GetAppSecurityKey`, `UpsertAppSecurityKey`, `GetOAuthSigningKey`,
`UpsertOAuthSigningKey`, `GetCoordinatorResumeTokenSigningKey`,
`UpsertCoordinatorResumeTokenSigningKey`

**Superseded queries (4):**
- `GetProvisionerJobsByIDs` → `GetProvisionerJobsByIDsWithQueuePosition`
- `GetDeploymentDAUs` / `GetTemplateDAUs` →
`GetTemplateInsightsByInterval`
- `GetWorkspaceBuildParametersByBuildIDs` + its `GetAuthorized...`
variant → unused

**OAuth2 (2):**
`GetOAuth2ProviderAppByRegistrationToken`,
`UpdateOAuth2ProviderAppSecretByID`

**Chat (4)** — pre-wired with no callers:
`GetChatModelConfigByProviderAndModel`, `DeleteChatMessagesByChatID`,
`ListChatsByRootID`, `ListChildChatsByParentID`

**Other (6):**
`DeleteGitSSHKey`, `UpdateUserLinkedID`, `GetFileIDByTemplateVersionID`,
`GetTemplateVersionHasAITask`, `InsertUserGroupsByName`,
`RemoveUserFromAllGroups`
This commit is contained in:
Cian Johnston
2026-03-12 21:32:57 +00:00
committed by GitHub
parent 4b8c079eef
commit e9025f91e8
19 changed files with 0 additions and 1688 deletions
@@ -16,21 +16,6 @@ WHERE
is_default = TRUE
AND deleted = FALSE;
-- name: GetChatModelConfigByProviderAndModel :one
SELECT
*
FROM
chat_model_configs
WHERE
provider = @provider::text
AND model = @model::text
AND deleted = FALSE
ORDER BY
updated_at DESC,
created_at DESC,
id DESC
LIMIT 1;
-- name: GetChatModelConfigs :many
SELECT
*
-26
View File
@@ -5,12 +5,6 @@ WHERE id = @id OR root_chat_id = @id;
-- name: UnarchiveChatByID :exec
UPDATE chats SET archived = false, updated_at = NOW() WHERE id = @id::uuid;
-- name: DeleteChatMessagesByChatID :exec
DELETE FROM
chat_messages
WHERE
chat_id = @chat_id::uuid;
-- name: DeleteChatMessagesAfterID :exec
DELETE FROM
chat_messages
@@ -141,26 +135,6 @@ LIMIT
-- Default to 50 to prevent accidental excessively large queries.
COALESCE(NULLIF(@limit_opt :: int, 0), 50);
-- name: ListChildChatsByParentID :many
SELECT
*
FROM
chats
WHERE
parent_chat_id = @parent_chat_id::uuid
ORDER BY
created_at ASC;
-- name: ListChatsByRootID :many
SELECT
*
FROM
chats
WHERE
root_chat_id = @root_chat_id::uuid
ORDER BY
created_at ASC;
-- name: InsertChat :one
INSERT INTO chats (
owner_id,
-16
View File
@@ -8,22 +8,6 @@ WHERE
LIMIT
1;
-- name: GetFileIDByTemplateVersionID :one
SELECT
files.id
FROM
files
JOIN
provisioner_jobs ON
provisioner_jobs.storage_method = 'file'
AND provisioner_jobs.file_id = files.id
JOIN
template_versions ON template_versions.job_id = provisioner_jobs.id
WHERE
template_versions.id = @template_version_id
LIMIT
1;
-- name: GetFileByHashAndCreator :one
SELECT
-5
View File
@@ -30,8 +30,3 @@ WHERE
RETURNING
*;
-- name: DeleteGitSSHKey :exec
DELETE FROM
gitsshkeys
WHERE
user_id = $1;
-25
View File
@@ -31,25 +31,6 @@ WHERE group_id = @group_id
user_is_system = false
END;
-- InsertUserGroupsByName adds a user to all provided groups, if they exist.
-- name: InsertUserGroupsByName :exec
WITH groups AS (
SELECT
id
FROM
groups
WHERE
groups.organization_id = @organization_id AND
groups.name = ANY(@group_names :: text [])
)
INSERT INTO
group_members (user_id, group_id)
SELECT
@user_id,
groups.id
FROM
groups;
-- InsertUserGroupsByID adds a user to all provided groups, if they exist.
-- name: InsertUserGroupsByID :many
WITH groups AS (
@@ -71,12 +52,6 @@ FROM
ON CONFLICT DO NOTHING
RETURNING group_id;
-- name: RemoveUserFromAllGroups :exec
DELETE FROM
group_members
WHERE
user_id = @user_id;
-- name: RemoveUserFromGroups :many
DELETE FROM
group_members
-7
View File
@@ -115,11 +115,6 @@ INSERT INTO oauth2_provider_app_secrets (
$6
) RETURNING *;
-- name: UpdateOAuth2ProviderAppSecretByID :one
UPDATE oauth2_provider_app_secrets SET
last_used_at = $2
WHERE id = $1 RETURNING *;
-- name: DeleteOAuth2ProviderAppSecretByID :exec
DELETE FROM oauth2_provider_app_secrets WHERE id = $1;
@@ -249,5 +244,3 @@ WHERE id = $1 RETURNING *;
-- name: DeleteOAuth2ProviderAppByClientID :exec
DELETE FROM oauth2_provider_apps WHERE id = $1;
-- name: GetOAuth2ProviderAppByRegistrationToken :one
SELECT * FROM oauth2_provider_apps WHERE registration_access_token = $1;
@@ -67,14 +67,6 @@ WHERE
id = $1
FOR UPDATE;
-- name: GetProvisionerJobsByIDs :many
SELECT
*
FROM
provisioner_jobs
WHERE
id = ANY(@ids :: uuid [ ]);
-- name: GetProvisionerJobsByIDsWithQueuePosition :many
WITH filtered_provisioner_jobs AS (
-- Step 1: Filter provisioner_jobs
-21
View File
@@ -57,27 +57,6 @@ ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'application
-- name: GetApplicationName :one
SELECT value FROM site_configs WHERE key = 'application_name';
-- name: GetAppSecurityKey :one
SELECT value FROM site_configs WHERE key = 'app_signing_key';
-- name: UpsertAppSecurityKey :exec
INSERT INTO site_configs (key, value) VALUES ('app_signing_key', $1)
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'app_signing_key';
-- name: GetOAuthSigningKey :one
SELECT value FROM site_configs WHERE key = 'oauth_signing_key';
-- name: UpsertOAuthSigningKey :exec
INSERT INTO site_configs (key, value) VALUES ('oauth_signing_key', $1)
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'oauth_signing_key';
-- name: GetCoordinatorResumeTokenSigningKey :one
SELECT value FROM site_configs WHERE key = 'coordinator_resume_token_signing_key';
-- name: UpsertCoordinatorResumeTokenSigningKey :exec
INSERT INTO site_configs (key, value) VALUES ('coordinator_resume_token_signing_key', $1)
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'coordinator_resume_token_signing_key';
-- name: GetHealthSettings :one
SELECT
COALESCE((SELECT value FROM site_configs WHERE key = 'health_settings'), '{}') :: text AS health_settings
@@ -226,13 +226,6 @@ WHERE
template_versions.id IN (archived_versions.id)
RETURNING template_versions.id;
-- name: GetTemplateVersionHasAITask :one
SELECT EXISTS (
SELECT 1
FROM template_versions
WHERE id = $1 AND has_ai_task = TRUE
);
-- name: UpdateTemplateVersionFlagsByJobID :exec
UPDATE
template_versions
-8
View File
@@ -37,14 +37,6 @@ INSERT INTO
VALUES
( $1, $2, $3, $4, $5, $6, $7, $8, $9 ) RETURNING *;
-- name: UpdateUserLinkedID :one
UPDATE
user_links
SET
linked_id = $1
WHERE
user_id = $2 AND login_type = $3 RETURNING *;
-- name: UpdateUserLink :one
UPDATE
user_links
@@ -40,33 +40,6 @@ SELECT
unnest(@connection_median_latency_ms :: double precision[]) AS connection_median_latency_ms,
unnest(@usage :: boolean[]) AS usage;
-- name: GetTemplateDAUs :many
SELECT
(created_at at TIME ZONE cast(@tz_offset::integer as text))::date as date,
user_id
FROM
workspace_agent_stats
WHERE
template_id = $1 AND
connection_count > 0
GROUP BY
date, user_id
ORDER BY
date ASC;
-- name: GetDeploymentDAUs :many
SELECT
(created_at at TIME ZONE cast(@tz_offset::integer as text))::date as date,
user_id
FROM
workspace_agent_stats
WHERE
connection_count > 0
GROUP BY
date, user_id
ORDER BY
date ASC;
-- name: DeleteOldWorkspaceAgentStats :exec
DELETE FROM
workspace_agent_stats
@@ -42,17 +42,3 @@ FROM (
ORDER BY created_at DESC, name
LIMIT 100;
-- name: GetWorkspaceBuildParametersByBuildIDs :many
SELECT
workspace_build_parameters.*
FROM
workspace_build_parameters
JOIN
workspace_builds ON workspace_builds.id = workspace_build_parameters.workspace_build_id
JOIN
workspaces ON workspaces.id = workspace_builds.workspace_id
WHERE
workspace_build_parameters.workspace_build_id = ANY(@workspace_build_ids :: uuid[])
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaceBuildParametersByBuildIDs
-- @authorize_filter
;