Squash the pre-production migration history into fresh core, fedwiki, and stripe baselines and reduce the canonical source list to those three streams. Update sqlc configs, generated queries, raw SQL, tests, and docs while keeping provider tables schema-qualified. BREAKING: existing local database volumes must be wiped because goose version history restarts from the new baselines.
95 lines
2.4 KiB
Go
95 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: users.sql
|
|
|
|
package identity
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO core.users (oidc_subject)
|
|
VALUES ($1)
|
|
RETURNING user_id, oidc_subject, status, last_login_at, last_login_ip, created_at, updated_at
|
|
`
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, oidcSubject string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUser, oidcSubject)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.OidcSubject,
|
|
&i.Status,
|
|
&i.LastLoginAt,
|
|
&i.LastLoginIp,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const ensureSystemUser = `-- name: EnsureSystemUser :exec
|
|
INSERT INTO core.users (oidc_subject)
|
|
VALUES ($1)
|
|
ON CONFLICT (oidc_subject) DO NOTHING
|
|
`
|
|
|
|
// Idempotently insert the reserved, non-loginable system user (keyed on the
|
|
// unique oidc_subject sentinel). Safe under concurrent boots; read back with
|
|
// GetUserByOIDCSubject.
|
|
func (q *Queries) EnsureSystemUser(ctx context.Context, oidcSubject string) error {
|
|
_, err := q.db.ExecContext(ctx, ensureSystemUser, oidcSubject)
|
|
return err
|
|
}
|
|
|
|
const getUserByOIDCSubject = `-- name: GetUserByOIDCSubject :one
|
|
SELECT user_id, oidc_subject, status, last_login_at, last_login_ip, created_at, updated_at FROM core.users
|
|
WHERE oidc_subject = $1
|
|
`
|
|
|
|
func (q *Queries) GetUserByOIDCSubject(ctx context.Context, oidcSubject string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByOIDCSubject, oidcSubject)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.OidcSubject,
|
|
&i.Status,
|
|
&i.LastLoginAt,
|
|
&i.LastLoginIp,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateUserLogin = `-- name: UpdateUserLogin :one
|
|
UPDATE core.users
|
|
SET last_login_at = $1, last_login_ip = $2
|
|
WHERE user_id = $3
|
|
RETURNING user_id, oidc_subject, status, last_login_at, last_login_ip, created_at, updated_at
|
|
`
|
|
|
|
type UpdateUserLoginParams struct {
|
|
LastLoginAt sql.NullTime `json:"last_login_at"`
|
|
LastLoginIp sql.NullString `json:"last_login_ip"`
|
|
UserID string `json:"user_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateUserLogin(ctx context.Context, arg UpdateUserLoginParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, updateUserLogin, arg.LastLoginAt, arg.LastLoginIp, arg.UserID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.OidcSubject,
|
|
&i.Status,
|
|
&i.LastLoginAt,
|
|
&i.LastLoginIp,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|