dev: automated commit - 2025-06-17 16:15:21
This commit is contained in:
parent
73e91db78b
commit
27775e6b29
16 changed files with 1860 additions and 1240 deletions
|
@ -9,6 +9,15 @@ import (
|
|||
"context"
|
||||
)
|
||||
|
||||
const deleteAllConfig = `-- name: DeleteAllConfig :exec
|
||||
DELETE FROM config
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAllConfig(ctx context.Context) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteAllConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
const getConfig = `-- name: GetConfig :one
|
||||
SELECT api_token, zone_id, domain, update_period FROM config LIMIT 1
|
||||
`
|
||||
|
@ -27,19 +36,40 @@ func (q *Queries) GetConfig(ctx context.Context) (Config, error) {
|
|||
|
||||
const initSchema = `-- name: InitSchema :exec
|
||||
CREATE TABLE IF NOT EXISTS config (
|
||||
api_token TEXT,
|
||||
zone_id TEXT,
|
||||
api_token TEXT NOT NULL DEFAULT '',
|
||||
zone_id TEXT NOT NULL DEFAULT '',
|
||||
domain TEXT NOT NULL DEFAULT 'mz.uy',
|
||||
update_period TEXT NOT NULL DEFAULT '0 */6 * * *'
|
||||
)
|
||||
`
|
||||
|
||||
// This query is used to ensure the schema is set up properly
|
||||
func (q *Queries) InitSchema(ctx context.Context) error {
|
||||
_, err := q.db.ExecContext(ctx, initSchema)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertConfig = `-- name: InsertConfig :exec
|
||||
INSERT INTO config (api_token, zone_id, domain, update_period)
|
||||
VALUES (?, ?, ?, ?)
|
||||
`
|
||||
|
||||
type InsertConfigParams struct {
|
||||
ApiToken string `json:"api_token"`
|
||||
ZoneID string `json:"zone_id"`
|
||||
Domain string `json:"domain"`
|
||||
UpdatePeriod string `json:"update_period"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertConfig(ctx context.Context, arg InsertConfigParams) error {
|
||||
_, err := q.db.ExecContext(ctx, insertConfig,
|
||||
arg.ApiToken,
|
||||
arg.ZoneID,
|
||||
arg.Domain,
|
||||
arg.UpdatePeriod,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertConfig = `-- name: UpsertConfig :exec
|
||||
INSERT INTO config (api_token, zone_id, domain, update_period)
|
||||
VALUES (?, ?, ?, ?)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue