Files
OwnCord/Server/db/pgdbgen/roles.sql.go
T
J3vb 9116a880a3 feat(phase-bc): pass 5 — pgdbgen, postgres EventStore/PluginStore, plugin hub wiring, OTel stack, reconnect DB tier
- Generate Server/db/dbgen/{events,plugins}.sql.go and full Server/db/pgdbgen/ (//go:build postgres gated)
- Implement PostgresStore EventStore and PluginStore methods in store/postgres.go
- Wire plugin host_events.go EventSink into hub broadcast path (SetPluginEventSink)
- Wire host_commands.go slash-command dispatcher: chat_command V1 handler + hub.SetPluginRegistry
- Add handlers_command.go + handlers_command_test.go for plugin slash-command dispatch
- Add reconnect_db_test.go: TestReconnect_BufferMiss_FallsBackToDBTier (cold-tier DB replay)
- Add otel-up/otel-down Makefile targets; docker-compose.otel.yml + prometheus.dev.yml
- Update PHASE_BC_LOCAL_TODO.md: mark in-session items complete; document remaining network-blocked steps
- Minor fixes: channel_handler access-control, router plugin handler wiring, service span instrumentation
2026-04-06 22:48:59 +02:00

166 lines
3.8 KiB
Go

//go:build postgres
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: roles.sql
package pgdbgen
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getDefaultRole = `-- name: GetDefaultRole :one
SELECT id, name, color, permissions, position, is_default
FROM roles WHERE is_default = TRUE LIMIT 1
`
func (q *Queries) GetDefaultRole(ctx context.Context) (Role, error) {
row := q.db.QueryRow(ctx, getDefaultRole)
var i Role
err := row.Scan(
&i.ID,
&i.Name,
&i.Color,
&i.Permissions,
&i.Position,
&i.IsDefault,
)
return i, err
}
const getRoleByID = `-- name: GetRoleByID :one
SELECT id, name, color, permissions, position, is_default
FROM roles WHERE id = $1
`
// PostgreSQL variants of the sqlite roles queries.
// `is_default = 1` becomes `is_default = TRUE` since the column is BOOLEAN.
func (q *Queries) GetRoleByID(ctx context.Context, id int64) (Role, error) {
row := q.db.QueryRow(ctx, getRoleByID, id)
var i Role
err := row.Scan(
&i.ID,
&i.Name,
&i.Color,
&i.Permissions,
&i.Position,
&i.IsDefault,
)
return i, err
}
const getRoleForUser = `-- name: GetRoleForUser :one
SELECT r.id, r.name, r.color, r.permissions, r.position, r.is_default
FROM users u
JOIN roles r ON u.role_id = r.id
WHERE u.id = $1
`
func (q *Queries) GetRoleForUser(ctx context.Context, id int64) (Role, error) {
row := q.db.QueryRow(ctx, getRoleForUser, id)
var i Role
err := row.Scan(
&i.ID,
&i.Name,
&i.Color,
&i.Permissions,
&i.Position,
&i.IsDefault,
)
return i, err
}
const getUserWithRole = `-- name: GetUserWithRole :one
SELECT u.id, u.username, u.password, u.avatar, u.role_id,
u.totp_secret, u.status, u.created_at, u.last_seen,
u.banned, u.ban_reason, u.ban_expires,
r.id, r.name, r.color, r.permissions, r.position, r.is_default
FROM users u
JOIN roles r ON r.id = u.role_id
WHERE u.id = $1
`
type GetUserWithRoleRow struct {
ID int64 `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Avatar *string `json:"avatar"`
RoleID int64 `json:"roleId"`
TotpSecret *string `json:"totpSecret"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"createdAt"`
LastSeen pgtype.Timestamptz `json:"lastSeen"`
Banned bool `json:"banned"`
BanReason *string `json:"banReason"`
BanExpires pgtype.Timestamptz `json:"banExpires"`
ID_2 int64 `json:"id2"`
Name string `json:"name"`
Color *string `json:"color"`
Permissions int64 `json:"permissions"`
Position int32 `json:"position"`
IsDefault bool `json:"isDefault"`
}
func (q *Queries) GetUserWithRole(ctx context.Context, id int64) (GetUserWithRoleRow, error) {
row := q.db.QueryRow(ctx, getUserWithRole, id)
var i GetUserWithRoleRow
err := row.Scan(
&i.ID,
&i.Username,
&i.Password,
&i.Avatar,
&i.RoleID,
&i.TotpSecret,
&i.Status,
&i.CreatedAt,
&i.LastSeen,
&i.Banned,
&i.BanReason,
&i.BanExpires,
&i.ID_2,
&i.Name,
&i.Color,
&i.Permissions,
&i.Position,
&i.IsDefault,
)
return i, err
}
const listRoles = `-- name: ListRoles :many
SELECT id, name, color, permissions, position, is_default
FROM roles ORDER BY position DESC
`
func (q *Queries) ListRoles(ctx context.Context) ([]Role, error) {
rows, err := q.db.Query(ctx, listRoles)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Role{}
for rows.Next() {
var i Role
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Color,
&i.Permissions,
&i.Position,
&i.IsDefault,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}