bluebell/database/sites.sql.go

80 lines
1.9 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: sites.sql
package database
import (
"context"
"time"
)
const addSiteDomain = `-- name: AddSiteDomain :exec
INSERT INTO sites (domain, token)
VALUES (?, ?)
`
type AddSiteDomainParams struct {
Domain string `json:"domain"`
Token string `json:"token"`
}
func (q *Queries) AddSiteDomain(ctx context.Context, arg AddSiteDomainParams) error {
_, err := q.db.ExecContext(ctx, addSiteDomain, arg.Domain, arg.Token)
return err
}
const getLastUpdatedByDomainBranch = `-- name: GetLastUpdatedByDomainBranch :one
SELECT last_update
FROM branches
WHERE domain = ?
AND branch = ?
AND enable = true
LIMIT 1
`
type GetLastUpdatedByDomainBranchParams struct {
Domain string `json:"domain"`
Branch string `json:"branch"`
}
func (q *Queries) GetLastUpdatedByDomainBranch(ctx context.Context, arg GetLastUpdatedByDomainBranchParams) (time.Time, error) {
row := q.db.QueryRowContext(ctx, getLastUpdatedByDomainBranch, arg.Domain, arg.Branch)
var last_update time.Time
err := row.Scan(&last_update)
return last_update, err
}
const getSiteByDomain = `-- name: GetSiteByDomain :one
SELECT id, domain, token
FROM sites
WHERE domain = ?
LIMIT 1
`
func (q *Queries) GetSiteByDomain(ctx context.Context, domain string) (Site, error) {
row := q.db.QueryRowContext(ctx, getSiteByDomain, domain)
var i Site
err := row.Scan(&i.ID, &i.Domain, &i.Token)
return i, err
}
const setDomainBranchEnabled = `-- name: SetDomainBranchEnabled :exec
UPDATE branches
SET enable = ?
WHERE domain = ?
AND branch = ?
`
type SetDomainBranchEnabledParams struct {
Enable bool `json:"enable"`
Domain string `json:"domain"`
Branch string `json:"branch"`
}
func (q *Queries) SetDomainBranchEnabled(ctx context.Context, arg SetDomainBranchEnabledParams) error {
_, err := q.db.ExecContext(ctx, setDomainBranchEnabled, arg.Enable, arg.Domain, arg.Branch)
return err
}