sqlc fix
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: keys.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getKeyByHash = `-- name: GetKeyByHash :one
|
||||
SELECT k.id, k.owner_id, k.scopes, k.quota_tier, k.status, k.expires_at,
|
||||
o.status AS owner_status
|
||||
FROM api.keys k
|
||||
JOIN api.owners o ON o.id = k.owner_id
|
||||
WHERE k.key_hash = $1 AND k.status = 'active'
|
||||
`
|
||||
|
||||
type GetKeyByHashRow struct {
|
||||
ID int64
|
||||
OwnerID int64
|
||||
Scopes []string
|
||||
QuotaTier string
|
||||
Status string
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
OwnerStatus string
|
||||
}
|
||||
|
||||
func (q *Queries) GetKeyByHash(ctx context.Context, keyHash []byte) (GetKeyByHashRow, error) {
|
||||
row := q.db.QueryRow(ctx, getKeyByHash, keyHash)
|
||||
var i GetKeyByHashRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.OwnerID,
|
||||
&i.Scopes,
|
||||
&i.QuotaTier,
|
||||
&i.Status,
|
||||
&i.ExpiresAt,
|
||||
&i.OwnerStatus,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
// Several active keys per owner is intentional: people leak keys into public repositories, and rotating needs an overlap window where both the old and new key work.
|
||||
type ApiKey struct {
|
||||
ID int64
|
||||
OwnerID int64
|
||||
KeyHash []byte
|
||||
KeyPrefix string
|
||||
Label *string
|
||||
Scopes []string
|
||||
QuotaTier string
|
||||
Status string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
LastUsedAt pgtype.Timestamptz
|
||||
RevokedAt pgtype.Timestamptz
|
||||
RevokedReason *string
|
||||
}
|
||||
|
||||
// Registrants for API keys. Holds PII from an international user base, so the deletion path in 005_privacy.sql applies here too, not just to Discord users.
|
||||
type ApiOwner struct {
|
||||
ID int64
|
||||
Email interface{}
|
||||
EmailVerifiedAt pgtype.Timestamptz
|
||||
Callsign interface{}
|
||||
CallsignVerifiedAt pgtype.Timestamptz
|
||||
Status string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ApiUsageDaily struct {
|
||||
KeyID int64
|
||||
Day pgtype.Date
|
||||
Endpoint string
|
||||
Calls int64
|
||||
Errors int64
|
||||
DistinctUsers int32
|
||||
}
|
||||
|
||||
type CoreSubscription struct {
|
||||
ID int64
|
||||
GuildID *int64
|
||||
ChannelID int64
|
||||
UserID *int64
|
||||
Kind string
|
||||
Filters []byte
|
||||
Enabled bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// One row per Discord user who has interacted with a stateful command. Deliberately no soft-delete column: a deletion request must actually remove the row, so there is nothing left to resurrect.
|
||||
type CoreUser struct {
|
||||
ID int64
|
||||
DiscordID int64
|
||||
Callsign interface{}
|
||||
CallsignVerifiedAt pgtype.Timestamptz
|
||||
VerificationMethod *string
|
||||
Grid interface{}
|
||||
Timezone *string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type CoreVerification struct {
|
||||
ID int64
|
||||
UserID int64
|
||||
Method string
|
||||
Callsign interface{}
|
||||
Status string
|
||||
ChallengeHash []byte
|
||||
Detail []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
CompletedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type LogbookImport struct {
|
||||
ID int64
|
||||
UserID int64
|
||||
Filename *string
|
||||
Source *string
|
||||
Status string
|
||||
RowsTotal int32
|
||||
RowsAccepted int32
|
||||
RowsDuplicate int32
|
||||
RowsRejected int32
|
||||
Error *string
|
||||
StartedAt pgtype.Timestamptz
|
||||
FinishedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type LogbookQso struct {
|
||||
ID int64
|
||||
UserID int64
|
||||
ImportID *int64
|
||||
Callsign interface{}
|
||||
QsoAt pgtype.Timestamptz
|
||||
// Truncated copy of qso_at used only for duplicate detection. Do not query it directly; use qso_at.
|
||||
QsoMinute pgtype.Timestamp
|
||||
Band *string
|
||||
Mode *string
|
||||
Submode *string
|
||||
FreqHz *int64
|
||||
RstSent *string
|
||||
RstRcvd *string
|
||||
Grid interface{}
|
||||
Dxcc *int32
|
||||
CqZone *int16
|
||||
ItuZone *int16
|
||||
TxPowerW pgtype.Numeric
|
||||
Comment *string
|
||||
Extra []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
@@ -4,10 +4,10 @@ sql:
|
||||
- engine: "postgresql"
|
||||
queries: "queries"
|
||||
schema:
|
||||
- "migrations/002_types.sql"
|
||||
- "migrations/003_core.sql"
|
||||
- "migrations/004_api.sql"
|
||||
- "migrations/005_logbook.sql"
|
||||
- "migrations/001_types.sql"
|
||||
- "migrations/002_core.sql"
|
||||
- "migrations/003_api.sql"
|
||||
- "migrations/004_logbook.sql"
|
||||
gen:
|
||||
go:
|
||||
package: "db"
|
||||
|
||||
Reference in New Issue
Block a user