2024-08-10 13:28:30 +01:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.25.0
|
|
|
|
// source: sites.sql
|
|
|
|
|
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2025-01-05 18:41:38 +00:00
|
|
|
"time"
|
2024-08-10 13:28:30 +01:00
|
|
|
)
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
const addSiteDomain = `-- name: AddSiteDomain :exec
|
|
|
|
INSERT INTO sites (domain, token)
|
|
|
|
VALUES (?, ?)
|
2024-08-16 16:48:50 +01:00
|
|
|
`
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
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)
|
2024-08-16 16:48:50 +01:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
const getLastUpdatedByDomainBranch = `-- name: GetLastUpdatedByDomainBranch :one
|
|
|
|
SELECT last_update
|
|
|
|
FROM branches
|
|
|
|
WHERE domain = ?
|
|
|
|
AND branch = ?
|
|
|
|
AND enable = true
|
|
|
|
LIMIT 1
|
2024-08-16 16:48:50 +01:00
|
|
|
`
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
type GetLastUpdatedByDomainBranchParams struct {
|
2024-08-16 16:48:50 +01:00
|
|
|
Domain string `json:"domain"`
|
2025-01-05 18:41:38 +00:00
|
|
|
Branch string `json:"branch"`
|
2024-08-16 16:48:50 +01:00
|
|
|
}
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
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
|
2024-08-16 16:48:50 +01:00
|
|
|
}
|
|
|
|
|
2024-08-10 13:28:30 +01:00
|
|
|
const getSiteByDomain = `-- name: GetSiteByDomain :one
|
2025-01-05 18:41:38 +00:00
|
|
|
SELECT id, domain, token
|
2024-08-10 13:28:30 +01:00
|
|
|
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
|
2025-01-05 18:41:38 +00:00
|
|
|
err := row.Scan(&i.ID, &i.Domain, &i.Token)
|
2024-08-16 16:48:50 +01:00
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
const setDomainBranchEnabled = `-- name: SetDomainBranchEnabled :exec
|
|
|
|
UPDATE branches
|
|
|
|
SET enable = ?
|
|
|
|
WHERE domain = ?
|
|
|
|
AND branch = ?
|
2024-08-16 16:48:50 +01:00
|
|
|
`
|
|
|
|
|
2025-01-05 18:41:38 +00:00
|
|
|
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
|
2024-08-10 13:28:30 +01:00
|
|
|
}
|