mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- Add sqlc.yaml config (SQLite engine, db/queries/sqlite/, db/dbgen/ output) - Pin sqlc v1.30.0 in sqlc.version - Add Makefile with sqlc-install, sqlc-generate, sqlc-verify targets - Write 14 SQL query files covering all DB domains (users, sessions, invites, channels, messages, reactions, voice, roles, attachments, admin, dm, blocks, lockouts, profile) - Commit generated db/dbgen/ package (querier interface + typed fns) - FTS5 search queries remain hand-written in message_queries.go; transactional multi-step operations unchanged in Go
66 lines
2.2 KiB
SQL
66 lines
2.2 KiB
SQL
-- name: ListChannels :many
|
|
SELECT id, name, type, COALESCE(category, '') AS category, COALESCE(topic, '') AS topic,
|
|
position, slow_mode, archived, created_at,
|
|
COALESCE(voice_max_users, 0) AS voice_max_users,
|
|
voice_quality,
|
|
mixing_threshold,
|
|
COALESCE(voice_max_video, 0) AS voice_max_video
|
|
FROM channels ORDER BY position ASC, id ASC;
|
|
|
|
-- name: GetChannel :one
|
|
SELECT id, name, type, COALESCE(category, '') AS category, COALESCE(topic, '') AS topic,
|
|
position, slow_mode, archived, created_at,
|
|
COALESCE(voice_max_users, 0) AS voice_max_users,
|
|
voice_quality,
|
|
mixing_threshold,
|
|
COALESCE(voice_max_video, 0) AS voice_max_video
|
|
FROM channels WHERE id = ?;
|
|
|
|
-- name: CreateChannel :execresult
|
|
INSERT INTO channels (name, type, category, topic, position) VALUES (?, ?, ?, ?, ?);
|
|
|
|
-- name: UpdateChannel :exec
|
|
UPDATE channels SET name = ?, topic = ?, slow_mode = ? WHERE id = ?;
|
|
|
|
-- name: SetChannelSlowMode :exec
|
|
UPDATE channels SET slow_mode = ? WHERE id = ?;
|
|
|
|
-- name: SetChannelVoiceMaxUsers :exec
|
|
UPDATE channels SET voice_max_users = ? WHERE id = ?;
|
|
|
|
-- name: SetChannelVoiceMaxVideo :exec
|
|
UPDATE channels SET voice_max_video = ? WHERE id = ?;
|
|
|
|
-- name: SetChannelVoiceQuality :exec
|
|
UPDATE channels SET voice_quality = ? WHERE id = ?;
|
|
|
|
-- name: SetChannelMixingThreshold :exec
|
|
UPDATE channels SET mixing_threshold = ? WHERE id = ?;
|
|
|
|
-- name: ArchiveChannel :exec
|
|
UPDATE channels SET archived = ? WHERE id = ?;
|
|
|
|
-- name: DeleteChannel :exec
|
|
DELETE FROM channels WHERE id = ?;
|
|
|
|
-- name: AdminUpdateChannel :exec
|
|
UPDATE channels
|
|
SET name = ?, topic = ?, slow_mode = ?, position = ?, archived = ?
|
|
WHERE id = ?;
|
|
|
|
-- name: UpsertChannelPermission :exec
|
|
INSERT INTO channel_overrides (channel_id, role_id, allow, deny)
|
|
VALUES (?, ?, ?, ?)
|
|
ON CONFLICT(channel_id, role_id) DO UPDATE SET
|
|
allow = excluded.allow,
|
|
deny = excluded.deny;
|
|
|
|
-- name: GetChannelPermission :one
|
|
SELECT allow, deny FROM channel_overrides WHERE channel_id = ? AND role_id = ?;
|
|
|
|
-- name: GetRoleChannelPermissions :many
|
|
SELECT channel_id, allow, deny FROM channel_overrides WHERE role_id = ?;
|
|
|
|
-- name: DeleteChannelPermission :exec
|
|
DELETE FROM channel_overrides WHERE channel_id = ? AND role_id = ?;
|