mirror of
https://github.com/1f349/site-hosting.git
synced 2025-01-21 22:56:27 +00:00
136 lines
3.1 KiB
Go
136 lines
3.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: sites.sql
|
|
|
|
package database
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const addBranch = `-- name: AddBranch :exec
|
|
INSERT INTO branches (domain, branch, last_update, enable)
|
|
VALUES (?, ?, ?, ?)
|
|
`
|
|
|
|
type AddBranchParams struct {
|
|
Domain string `json:"domain"`
|
|
Branch string `json:"branch"`
|
|
LastUpdate time.Time `json:"last_update"`
|
|
Enable bool `json:"enable"`
|
|
}
|
|
|
|
func (q *Queries) AddBranch(ctx context.Context, arg AddBranchParams) error {
|
|
_, err := q.db.ExecContext(ctx, addBranch,
|
|
arg.Domain,
|
|
arg.Branch,
|
|
arg.LastUpdate,
|
|
arg.Enable,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const addSite = `-- name: AddSite :exec
|
|
INSERT INTO sites (domain, token)
|
|
VALUES (?, ?)
|
|
`
|
|
|
|
type AddSiteParams struct {
|
|
Domain string `json:"domain"`
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
func (q *Queries) AddSite(ctx context.Context, arg AddSiteParams) error {
|
|
_, err := q.db.ExecContext(ctx, addSite, 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 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.Domain, &i.Token)
|
|
return i, err
|
|
}
|
|
|
|
const setBranchEnabled = `-- name: SetBranchEnabled :exec
|
|
UPDATE branches
|
|
SET enable = ?
|
|
WHERE domain = ?
|
|
AND branch = ?
|
|
`
|
|
|
|
type SetBranchEnabledParams struct {
|
|
Enable bool `json:"enable"`
|
|
Domain string `json:"domain"`
|
|
Branch string `json:"branch"`
|
|
}
|
|
|
|
func (q *Queries) SetBranchEnabled(ctx context.Context, arg SetBranchEnabledParams) error {
|
|
_, err := q.db.ExecContext(ctx, setBranchEnabled, arg.Enable, arg.Domain, arg.Branch)
|
|
return err
|
|
}
|
|
|
|
const updateBranch = `-- name: UpdateBranch :exec
|
|
UPDATE branches
|
|
SET last_update = ?
|
|
WHERE domain = ?
|
|
AND branch = ?
|
|
`
|
|
|
|
type UpdateBranchParams struct {
|
|
LastUpdate time.Time `json:"last_update"`
|
|
Domain string `json:"domain"`
|
|
Branch string `json:"branch"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBranch(ctx context.Context, arg UpdateBranchParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateBranch, arg.LastUpdate, arg.Domain, arg.Branch)
|
|
return err
|
|
}
|
|
|
|
const updateSiteToken = `-- name: UpdateSiteToken :exec
|
|
UPDATE sites
|
|
SET token = ?
|
|
WHERE domain = ?
|
|
`
|
|
|
|
type UpdateSiteTokenParams struct {
|
|
Token string `json:"token"`
|
|
Domain string `json:"domain"`
|
|
}
|
|
|
|
func (q *Queries) UpdateSiteToken(ctx context.Context, arg UpdateSiteTokenParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateSiteToken, arg.Token, arg.Domain)
|
|
return err
|
|
}
|