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:
@@ -71,15 +71,6 @@ type Ebooks struct {
|
|||||||
DatePublished pgtype.Date `db:"date_published" json:"date_published"`
|
DatePublished pgtype.Date `db:"date_published" json:"date_published"`
|
||||||
Publisher pgtype.Text `db:"publisher" json:"publisher"`
|
Publisher pgtype.Text `db:"publisher" json:"publisher"`
|
||||||
Contributors pgtype.Text `db:"contributors" json:"contributors"`
|
Contributors pgtype.Text `db:"contributors" json:"contributors"`
|
||||||
Language pgtype.Text `db:"language" json:"language"`
|
|
||||||
Edition pgtype.Text `db:"edition" json:"edition"`
|
|
||||||
PageCount pgtype.Int4 `db:"page_count" json:"page_count"`
|
|
||||||
GoodreadsID pgtype.Text `db:"goodreads_id" json:"goodreads_id"`
|
|
||||||
OpenlibraryID pgtype.Text `db:"openlibrary_id" json:"openlibrary_id"`
|
|
||||||
GoogleBooksID pgtype.Text `db:"google_books_id" json:"google_books_id"`
|
|
||||||
CopyrightYear pgtype.Int4 `db:"copyright_year" json:"copyright_year"`
|
|
||||||
Genre pgtype.Text `db:"genre" json:"genre"`
|
|
||||||
Subjects []string `db:"subjects" json:"subjects"`
|
|
||||||
AddedByAdminID pgtype.UUID `db:"added_by_admin_id" json:"added_by_admin_id"`
|
AddedByAdminID pgtype.UUID `db:"added_by_admin_id" json:"added_by_admin_id"`
|
||||||
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
||||||
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
||||||
@@ -150,15 +141,6 @@ type MediaItems struct {
|
|||||||
DatePublished pgtype.Date `db:"date_published" json:"date_published"`
|
DatePublished pgtype.Date `db:"date_published" json:"date_published"`
|
||||||
Publisher pgtype.Text `db:"publisher" json:"publisher"`
|
Publisher pgtype.Text `db:"publisher" json:"publisher"`
|
||||||
Contributors pgtype.Text `db:"contributors" json:"contributors"`
|
Contributors pgtype.Text `db:"contributors" json:"contributors"`
|
||||||
Language pgtype.Text `db:"language" json:"language"`
|
|
||||||
Edition pgtype.Text `db:"edition" json:"edition"`
|
|
||||||
PageCount pgtype.Int4 `db:"page_count" json:"page_count"`
|
|
||||||
GoodreadsID pgtype.Text `db:"goodreads_id" json:"goodreads_id"`
|
|
||||||
OpenlibraryID pgtype.Text `db:"openlibrary_id" json:"openlibrary_id"`
|
|
||||||
GoogleBooksID pgtype.Text `db:"google_books_id" json:"google_books_id"`
|
|
||||||
CopyrightYear pgtype.Int4 `db:"copyright_year" json:"copyright_year"`
|
|
||||||
Genre pgtype.Text `db:"genre" json:"genre"`
|
|
||||||
Subjects []string `db:"subjects" json:"subjects"`
|
|
||||||
AddedByAdminID pgtype.UUID `db:"added_by_admin_id" json:"added_by_admin_id"`
|
AddedByAdminID pgtype.UUID `db:"added_by_admin_id" json:"added_by_admin_id"`
|
||||||
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
||||||
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
||||||
|
|||||||
@@ -14,13 +14,8 @@ type Querier interface {
|
|||||||
// Library Folders queries
|
// Library Folders queries
|
||||||
AddLibraryFolder(ctx context.Context, arg AddLibraryFolderParams) (LibraryFolders, error)
|
AddLibraryFolder(ctx context.Context, arg AddLibraryFolderParams) (LibraryFolders, error)
|
||||||
CleanupExpiredRefreshTokens(ctx context.Context) error
|
CleanupExpiredRefreshTokens(ctx context.Context) error
|
||||||
CreateEbook(ctx context.Context, arg CreateEbookParams) (MediaItems, error)
|
|
||||||
// Backward compatibility - Ebook Highlights queries (using views)
|
|
||||||
CreateEbookHighlight(ctx context.Context, arg CreateEbookHighlightParams) (MediaHighlights, error)
|
|
||||||
// Backward compatibility - Ebook Notes queries (using views)
|
// Backward compatibility - Ebook Notes queries (using views)
|
||||||
CreateEbookNote(ctx context.Context, arg CreateEbookNoteParams) (MediaNotes, error)
|
CreateEbookNote(ctx context.Context, arg CreateEbookNoteParams) (MediaNotes, error)
|
||||||
// Backward compatibility - Ebooks ratings (using views)
|
|
||||||
CreateEbookRating(ctx context.Context, arg CreateEbookRatingParams) (MediaRatings, error)
|
|
||||||
// Libraries queries
|
// Libraries queries
|
||||||
CreateLibrary(ctx context.Context, arg CreateLibraryParams) (Libraries, error)
|
CreateLibrary(ctx context.Context, arg CreateLibraryParams) (Libraries, error)
|
||||||
// Media Highlights queries
|
// Media Highlights queries
|
||||||
@@ -33,10 +28,7 @@ type Querier interface {
|
|||||||
// Refresh Tokens queries
|
// Refresh Tokens queries
|
||||||
CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (RefreshTokens, error)
|
CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (RefreshTokens, error)
|
||||||
CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error)
|
CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error)
|
||||||
DeleteEbook(ctx context.Context, id pgtype.UUID) error
|
|
||||||
DeleteEbookHighlight(ctx context.Context, id pgtype.UUID) error
|
|
||||||
DeleteEbookNote(ctx context.Context, id pgtype.UUID) error
|
DeleteEbookNote(ctx context.Context, id pgtype.UUID) error
|
||||||
DeleteEbookRating(ctx context.Context, arg DeleteEbookRatingParams) error
|
|
||||||
DeleteLibrary(ctx context.Context, id pgtype.UUID) error
|
DeleteLibrary(ctx context.Context, id pgtype.UUID) error
|
||||||
DeleteLibraryFolder(ctx context.Context, arg DeleteLibraryFolderParams) (LibraryFolders, error)
|
DeleteLibraryFolder(ctx context.Context, arg DeleteLibraryFolderParams) (LibraryFolders, error)
|
||||||
DeleteMediaHighlight(ctx context.Context, id pgtype.UUID) error
|
DeleteMediaHighlight(ctx context.Context, id pgtype.UUID) error
|
||||||
@@ -45,19 +37,8 @@ type Querier interface {
|
|||||||
DeleteMediaRating(ctx context.Context, arg DeleteMediaRatingParams) error
|
DeleteMediaRating(ctx context.Context, arg DeleteMediaRatingParams) error
|
||||||
DeleteReadingProgress(ctx context.Context, arg DeleteReadingProgressParams) error
|
DeleteReadingProgress(ctx context.Context, arg DeleteReadingProgressParams) error
|
||||||
DeleteUser(ctx context.Context, id pgtype.UUID) error
|
DeleteUser(ctx context.Context, id pgtype.UUID) error
|
||||||
// Backward compatibility - Ebooks queries (using views)
|
|
||||||
GetEbook(ctx context.Context, id pgtype.UUID) (Ebooks, error)
|
|
||||||
// Note: User ebook folders replaced by library folders system
|
|
||||||
// Legacy folder management is now handled through libraries
|
|
||||||
GetEbookByFilePath(ctx context.Context, filePath string) (Ebooks, error)
|
|
||||||
GetEbookHighlight(ctx context.Context, id pgtype.UUID) (EbookHighlights, error)
|
|
||||||
GetEbookHighlights(ctx context.Context, arg GetEbookHighlightsParams) ([]EbookHighlights, error)
|
|
||||||
GetEbookLibraryID(ctx context.Context) (pgtype.UUID, error)
|
|
||||||
GetEbookNote(ctx context.Context, id pgtype.UUID) (EbookNotes, error)
|
|
||||||
GetEbookNotes(ctx context.Context, arg GetEbookNotesParams) ([]EbookNotes, error)
|
|
||||||
GetEbookRating(ctx context.Context, arg GetEbookRatingParams) (EbookRatings, error)
|
|
||||||
GetEbookRatings(ctx context.Context, ebookID pgtype.UUID) ([]GetEbookRatingsRow, error)
|
|
||||||
GetLibrary(ctx context.Context, id pgtype.UUID) (GetLibraryRow, error)
|
GetLibrary(ctx context.Context, id pgtype.UUID) (GetLibraryRow, error)
|
||||||
|
GetLibraryByFolder(ctx context.Context, folderPath string) (GetLibraryByFolderRow, error)
|
||||||
GetLibraryFolders(ctx context.Context, libraryID pgtype.UUID) ([]LibraryFolders, error)
|
GetLibraryFolders(ctx context.Context, libraryID pgtype.UUID) ([]LibraryFolders, error)
|
||||||
GetLibraryType(ctx context.Context, id pgtype.UUID) (LibraryTypes, error)
|
GetLibraryType(ctx context.Context, id pgtype.UUID) (LibraryTypes, error)
|
||||||
GetLibraryTypeByName(ctx context.Context, name string) (LibraryTypes, error)
|
GetLibraryTypeByName(ctx context.Context, name string) (LibraryTypes, error)
|
||||||
@@ -82,7 +63,6 @@ type Querier interface {
|
|||||||
GetUserForLogin(ctx context.Context, email string) (GetUserForLoginRow, error)
|
GetUserForLogin(ctx context.Context, email string) (GetUserForLoginRow, error)
|
||||||
GetUserPasswordHash(ctx context.Context, id pgtype.UUID) (string, error)
|
GetUserPasswordHash(ctx context.Context, id pgtype.UUID) (string, error)
|
||||||
GetUserVisibleLibraries(ctx context.Context, userID pgtype.UUID) ([]GetUserVisibleLibrariesRow, error)
|
GetUserVisibleLibraries(ctx context.Context, userID pgtype.UUID) ([]GetUserVisibleLibrariesRow, error)
|
||||||
ListEbooks(ctx context.Context, arg ListEbooksParams) ([]Ebooks, error)
|
|
||||||
ListLibraries(ctx context.Context) ([]ListLibrariesRow, error)
|
ListLibraries(ctx context.Context) ([]ListLibrariesRow, error)
|
||||||
ListMediaItems(ctx context.Context, arg ListMediaItemsParams) ([]ListMediaItemsRow, error)
|
ListMediaItems(ctx context.Context, arg ListMediaItemsParams) ([]ListMediaItemsRow, error)
|
||||||
ListMediaItemsByLibrary(ctx context.Context, libraryID pgtype.UUID) ([]ListMediaItemsByLibraryRow, error)
|
ListMediaItemsByLibrary(ctx context.Context, libraryID pgtype.UUID) ([]ListMediaItemsByLibraryRow, error)
|
||||||
@@ -91,15 +71,14 @@ type Querier interface {
|
|||||||
ListUsers(ctx context.Context) ([]ListUsersRow, error)
|
ListUsers(ctx context.Context) ([]ListUsersRow, error)
|
||||||
RevokeAllUserRefreshTokens(ctx context.Context, userID pgtype.UUID) error
|
RevokeAllUserRefreshTokens(ctx context.Context, userID pgtype.UUID) error
|
||||||
RevokeRefreshToken(ctx context.Context, token string) error
|
RevokeRefreshToken(ctx context.Context, token string) error
|
||||||
|
// Note: User ebook folders replaced by library folders system
|
||||||
|
// Legacy folder management is now handled through libraries
|
||||||
// Search Media Items queries
|
// Search Media Items queries
|
||||||
SearchMediaItems(ctx context.Context, arg SearchMediaItemsParams) ([]SearchMediaItemsRow, error)
|
SearchMediaItems(ctx context.Context, arg SearchMediaItemsParams) ([]SearchMediaItemsRow, error)
|
||||||
SearchMediaItemsFuzzy(ctx context.Context, arg SearchMediaItemsFuzzyParams) ([]SearchMediaItemsFuzzyRow, error)
|
SearchMediaItemsFuzzy(ctx context.Context, arg SearchMediaItemsFuzzyParams) ([]SearchMediaItemsFuzzyRow, error)
|
||||||
// Library Visibility queries
|
// Library Visibility queries
|
||||||
SetLibraryVisibility(ctx context.Context, arg SetLibraryVisibilityParams) (LibraryVisibility, error)
|
SetLibraryVisibility(ctx context.Context, arg SetLibraryVisibilityParams) (LibraryVisibility, error)
|
||||||
UpdateEbook(ctx context.Context, arg UpdateEbookParams) (MediaItems, error)
|
|
||||||
UpdateEbookHighlight(ctx context.Context, arg UpdateEbookHighlightParams) (MediaHighlights, error)
|
|
||||||
UpdateEbookNote(ctx context.Context, arg UpdateEbookNoteParams) (MediaNotes, error)
|
UpdateEbookNote(ctx context.Context, arg UpdateEbookNoteParams) (MediaNotes, error)
|
||||||
UpdateEbookRating(ctx context.Context, arg UpdateEbookRatingParams) (MediaRatings, error)
|
|
||||||
UpdateEmail(ctx context.Context, arg UpdateEmailParams) error
|
UpdateEmail(ctx context.Context, arg UpdateEmailParams) error
|
||||||
UpdateLibrary(ctx context.Context, arg UpdateLibraryParams) (Libraries, error)
|
UpdateLibrary(ctx context.Context, arg UpdateLibraryParams) (Libraries, error)
|
||||||
UpdateMediaHighlight(ctx context.Context, arg UpdateMediaHighlightParams) (MediaHighlights, error)
|
UpdateMediaHighlight(ctx context.Context, arg UpdateMediaHighlightParams) (MediaHighlights, error)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -73,6 +73,11 @@ SELECT * FROM library_folders WHERE library_id = $1 ORDER BY created_at;
|
|||||||
-- name: DeleteLibraryFolder :one
|
-- name: DeleteLibraryFolder :one
|
||||||
DELETE FROM library_folders WHERE library_id = $1 AND folder_path = $2 RETURNING *;
|
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
|
-- Library Visibility queries
|
||||||
-- name: SetLibraryVisibility :one
|
-- name: SetLibraryVisibility :one
|
||||||
INSERT INTO library_visibility (user_id, library_id, is_visible)
|
INSERT INTO library_visibility (user_id, library_id, is_visible)
|
||||||
@@ -98,7 +103,7 @@ ORDER BY l.created_at DESC;
|
|||||||
-- Media Items queries
|
-- Media Items queries
|
||||||
-- name: CreateMediaItem :one
|
-- 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)
|
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 *;
|
RETURNING *;
|
||||||
|
|
||||||
-- name: GetMediaItem :one
|
-- name: GetMediaItem :one
|
||||||
@@ -241,7 +246,7 @@ LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
|||||||
UPDATE media_items SET
|
UPDATE media_items SET
|
||||||
title = $2,
|
title = $2,
|
||||||
author = $3,
|
author = $3,
|
||||||
isbn = normalize_isbn($4),
|
isbn = $4,
|
||||||
description = $5,
|
description = $5,
|
||||||
cover_image_path = $6,
|
cover_image_path = $6,
|
||||||
series = $7,
|
series = $7,
|
||||||
@@ -471,50 +476,4 @@ UPDATE refresh_tokens SET revoked_at = NOW() WHERE user_id = $1 AND revoked_at I
|
|||||||
-- name: CleanupExpiredRefreshTokens :exec
|
-- name: CleanupExpiredRefreshTokens :exec
|
||||||
DELETE FROM refresh_tokens WHERE expires_at < NOW() OR (revoked_at IS NOT NULL AND revoked_at < NOW() - INTERVAL '7 days');
|
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
|
-- 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;
|
|
||||||
Reference in New Issue
Block a user