dml

package
v0.18.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package dml provides the Postgres data manipulation language (DML) for Vela.

https://en.wikipedia.org/wiki/Data_manipulation_language

Usage:

import "github.com/go-vela/server/database/postgres/dml"

Index

Constants

View Source
const (
	// ListBuilds represents a query to
	// list all builds in the database.
	ListBuilds = `
SELECT *
FROM builds;
`

	// SelectBuildByID represents a query to select
	// a build for its id in the database.
	SelectBuildByID = `
SELECT *
FROM builds
WHERE id = ?
LIMIT 1;
`

	// SelectRepoBuild represents a query to select
	// a build for a repo_id in the database.
	SelectRepoBuild = `
SELECT *
FROM builds
WHERE repo_id = ?
AND number = ?
LIMIT 1;
`

	// SelectLastRepoBuild represents a query to select
	// the last build for a repo_id in the database.
	SelectLastRepoBuild = `
SELECT *
FROM builds
WHERE repo_id = ?
ORDER BY number DESC
LIMIT 1;
`

	// SelectLastRepoBuildByBranch represents a query to
	// select the last build for a repo_id and branch name
	// in the database.
	SelectLastRepoBuildByBranch = `
SELECT *
FROM builds
WHERE repo_id = ?
AND branch = ?
ORDER BY number DESC
LIMIT 1;
`

	// SelectBuildsCount represents a query to select
	// the count of builds in the database.
	SelectBuildsCount = `
SELECT count(*) as count
FROM builds;
`

	// SelectBuildsCountByStatus represents a query to select
	// the count of builds for a status in the database.
	SelectBuildsCountByStatus = `
SELECT count(*) as count
FROM builds
WHERE status = ?;
`

	// DeleteBuild represents a query to
	// remove a build from the database.
	DeleteBuild = `
DELETE
FROM builds
WHERE id = ?;
`

	// SelectPendingAndRunningBuilds represents a joined query
	// between the builds & repos table to select
	// the created builds that are in pending or running builds status
	// since the specified timeframe.
	SelectPendingAndRunningBuilds = `` /* 215-byte string literal not displayed */

)
View Source
const (
	// ListSecrets represents a query to
	// list all secrets in the database.
	//
	//nolint:gosec // ignore false positive
	ListSecrets = `
SELECT *
FROM secrets;
`

	// ListOrgSecrets represents a query to list all
	// secrets for a type and org in the database.
	//
	//nolint:gosec // ignore false positive
	ListOrgSecrets = `
SELECT *
FROM secrets
WHERE type = 'org'
AND org = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// ListRepoSecrets represents a query to list all
	// secrets for a type, org and repo in the database.
	//
	//nolint:gosec // ignore false positive
	ListRepoSecrets = `
SELECT *
FROM secrets
WHERE type = 'repo'
AND org = ?
AND repo = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// ListSharedSecrets represents a query to list all
	// secrets for a type, org and team in the database.
	//
	//nolint:gosec // ignore false positive
	ListSharedSecrets = `
SELECT *
FROM secrets
WHERE type = 'shared'
AND org = ?
AND team = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectOrgSecretsCount represents a query to select the
	// count of org secrets for an org in the database.
	//
	//nolint:gosec // ignore false positive
	SelectOrgSecretsCount = `
SELECT count(*) as count
FROM secrets
WHERE type = 'org'
AND org = ?;
`

	// SelectRepoSecretsCount represents a query to select the
	// count of repo secrets for an org and repo in the database.
	//
	//nolint:gosec // ignore false positive
	SelectRepoSecretsCount = `
SELECT count(*) as count
FROM secrets
WHERE type = 'repo'
AND org = ?
AND repo = ?;
`

	// SelectSharedSecretsCount represents a query to select the
	// count of shared secrets for an org and repo in the database.
	//
	//nolint:gosec // ignore false positive
	SelectSharedSecretsCount = `
SELECT count(*) as count
FROM secrets
WHERE type = 'shared'
AND org = ?
AND team = ?;
`

	// SelectOrgSecret represents a query to select a
	// secret for an org and name in the database.
	//
	//nolint:gosec // ignore false positive
	SelectOrgSecret = `
SELECT *
FROM secrets
WHERE type = 'org'
AND org = ?
AND name = ?
LIMIT 1;
`

	// SelectRepoSecret represents a query to select a
	// secret for an org, repo and name in the database.
	//
	//nolint:gosec // ignore false positive
	SelectRepoSecret = `
SELECT *
FROM secrets
WHERE type = 'repo'
AND org = ?
AND repo = ?
AND name = ?
LIMIT 1;
`

	// SelectSharedSecret represents a query to select a
	// secret for an org, team and name in the database.
	//
	//nolint:gosec // ignore false positive
	SelectSharedSecret = `
SELECT *
FROM secrets
WHERE type = 'shared'
AND org = ?
AND team = ?
AND name = ?
LIMIT 1;
`

	// DeleteSecret represents a query to
	// remove a secret from the database.
	//
	//nolint:gosec // ignore false positive
	DeleteSecret = `
DELETE
FROM secrets
WHERE id = ?;
`
)
View Source
const (
	// ListServices represents a query to
	// list all services in the database.
	ListServices = `
SELECT *
FROM services;
`

	// ListBuildServices represents a query to list
	// all services for a build_id in the database.
	ListBuildServices = `
SELECT *
FROM services
WHERE build_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectBuildServicesCount represents a query to select
	// the count of services for a build_id in the database.
	SelectBuildServicesCount = `
SELECT count(*) as count
FROM services
WHERE build_id = ?
`

	// SelectServiceImagesCount represents a query to select
	// the count of an images appearances in the database.
	SelectServiceImagesCount = `
SELECT image, count(image) as count
FROM services
GROUP BY image
`

	// SelectServiceStatusesCount represents a query to select
	// the count of service status appearances in the database.
	SelectServiceStatusesCount = `
SELECT status, count(status) as count
FROM services
GROUP BY status;
`

	// SelectBuildService represents a query to select a
	// service for a build_id and number in the database.
	SelectBuildService = `
SELECT *
FROM services
WHERE build_id = ?
AND number = ?
LIMIT 1;
`

	// DeleteService represents a query to
	// remove a service from the database.
	DeleteService = `
DELETE
FROM services
WHERE id = ?;
`
)
View Source
const (
	// ListSteps represents a query to
	// list all steps in the database.
	ListSteps = `
SELECT *
FROM steps;
`

	// ListBuildSteps represents a query to list
	// all steps for a build_id in the database.
	ListBuildSteps = `
SELECT *
FROM steps
WHERE build_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectBuildStepsCount represents a query to select
	// the count of steps for a build_id in the database.
	SelectBuildStepsCount = `
SELECT count(*) as count
FROM steps
WHERE build_id = ?
`

	// SelectStepImagesCount represents a query to select
	// the count of an images appearances in the database.
	SelectStepImagesCount = `
SELECT image, count(image) as count
FROM steps
GROUP BY image;
`

	// SelectStepStatusesCount represents a query to select
	// the count of a statuses appearances in the database.
	SelectStepStatusesCount = `
SELECT status, count(status) as count
FROM steps
GROUP BY status;
`

	// SelectBuildStep represents a query to select a
	// step for a build_id and number in the database.
	SelectBuildStep = `
SELECT *
FROM steps
WHERE build_id = ?
AND number = ?
LIMIT 1;
`

	// DeleteStep represents a query to
	// remove a step from the database.
	DeleteStep = `
DELETE
FROM steps
WHERE id = ?;
`
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL