fix: database queries and schema sync
- Remove references to non-existent columns (language, edition, page_count, etc.) - Fix CreateMediaItem and UpdateMediaItem queries - Remove normalize_isbn() function calls (moved to Go code) - Regenerate database code with sqlc generate - Add GetLibraryByFolder method to queries Fixes compiler error: s.db.GetLibraryByFolder undefined
This commit is contained in:
@@ -73,6 +73,11 @@ SELECT * FROM library_folders WHERE library_id = $1 ORDER BY created_at;
|
||||
-- name: DeleteLibraryFolder :one
|
||||
DELETE FROM library_folders WHERE library_id = $1 AND folder_path = $2 RETURNING *;
|
||||
|
||||
-- name: GetLibraryByFolder :one
|
||||
SELECT lf.library_id, l.* FROM library_folders lf
|
||||
JOIN libraries l ON lf.library_id = l.id
|
||||
WHERE lf.folder_path = $1;
|
||||
|
||||
-- Library Visibility queries
|
||||
-- name: SetLibraryVisibility :one
|
||||
INSERT INTO library_visibility (user_id, library_id, is_visible)
|
||||
@@ -98,7 +103,7 @@ ORDER BY l.created_at DESC;
|
||||
-- Media Items queries
|
||||
-- name: CreateMediaItem :one
|
||||
INSERT INTO media_items (library_id, title, author, isbn, description, file_path, file_size, mime_type, cover_image_path, series, series_number, tags, asin, date_published, publisher, contributors, added_by_admin_id)
|
||||
VALUES ($1, $2, $3, normalize_isbn($4), $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetMediaItem :one
|
||||
@@ -241,7 +246,7 @@ LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
||||
UPDATE media_items SET
|
||||
title = $2,
|
||||
author = $3,
|
||||
isbn = normalize_isbn($4),
|
||||
isbn = $4,
|
||||
description = $5,
|
||||
cover_image_path = $6,
|
||||
series = $7,
|
||||
@@ -471,50 +476,4 @@ UPDATE refresh_tokens SET revoked_at = NOW() WHERE user_id = $1 AND revoked_at I
|
||||
-- name: CleanupExpiredRefreshTokens :exec
|
||||
DELETE FROM refresh_tokens WHERE expires_at < NOW() OR (revoked_at IS NOT NULL AND revoked_at < NOW() - INTERVAL '7 days');
|
||||
|
||||
-- Media Items Admin Operations
|
||||
-- name: CreateMediaItem :one
|
||||
INSERT INTO media_items (
|
||||
library_id, title, author, isbn, description, file_path, file_size,
|
||||
mime_type, cover_image_path, series, series_number, tags, asin,
|
||||
date_published, publisher, contributors, language, edition, page_count,
|
||||
goodreads_id, openlibrary_id, google_books_id, copyright_year,
|
||||
genre, subjects, added_by_admin_id
|
||||
)
|
||||
VALUES (
|
||||
$1, $2, $3, normalize_isbn($4), $5, $6, $7,
|
||||
$8, $9, $10, $11, $12, $13,
|
||||
$14, $15, $16, $17, $18, $19,
|
||||
$20, $21, $22, $23,
|
||||
$24, $25, $26
|
||||
)
|
||||
RETURNING id;
|
||||
|
||||
-- name: UpdateMediaItem :one
|
||||
UPDATE media_items SET
|
||||
title = $2,
|
||||
author = $3,
|
||||
isbn = normalize_isbn($4),
|
||||
description = $5,
|
||||
cover_image_path = $6,
|
||||
series = $7,
|
||||
series_number = $8,
|
||||
tags = $9,
|
||||
asin = $10,
|
||||
date_published = $11,
|
||||
publisher = $12,
|
||||
contributors = $13,
|
||||
language = $14,
|
||||
edition = $15,
|
||||
page_count = $16,
|
||||
goodreads_id = $17,
|
||||
openlibrary_id = $18,
|
||||
google_books_id = $19,
|
||||
copyright_year = $20,
|
||||
genre = $21,
|
||||
subjects = $22,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteMediaItem :exec
|
||||
DELETE FROM media_items WHERE id = $1;
|
||||
-- Media Items Admin Operations
|
||||
Reference in New Issue
Block a user