fix: Remove unsupported check constraint from user_ebook_folders table
- Remove complex CHECK constraint with subquery that PostgreSQL doesn't support - Add comment explaining admin-only access is enforced at application level - Update role system notes to clarify access control implementation - Fix Bruno request failures due to missing database table
This commit is contained in:
@@ -68,10 +68,8 @@ CREATE TABLE user_ebook_folders (
|
|||||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
folder_path VARCHAR(500) NOT NULL,
|
folder_path VARCHAR(500) NOT NULL,
|
||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
UNIQUE(user_id, folder_path),
|
UNIQUE(user_id, folder_path)
|
||||||
CONSTRAINT admin_only_folder CHECK (EXISTS (
|
-- Note: Admin-only access is enforced at application level in handlers/auth.go
|
||||||
SELECT 1 FROM users WHERE id = user_id AND role = 'admin'
|
|
||||||
))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Create indexes for better query performance
|
-- Create indexes for better query performance
|
||||||
@@ -94,4 +92,5 @@ COMMENT ON COLUMN ebook_ratings.rating IS 'Rating scale 1-10 (odd numbers = half
|
|||||||
-- - Admin users can: add/edit/delete folders, scan ebooks, modify ebook metadata, delete ebooks
|
-- - Admin users can: add/edit/delete folders, scan ebooks, modify ebook metadata, delete ebooks
|
||||||
-- - Regular users can: view all ebooks, rate ebooks, track reading progress, manage their profile
|
-- - Regular users can: view all ebooks, rate ebooks, track reading progress, manage their profile
|
||||||
-- - To create first admin: UPDATE users SET role = 'admin' WHERE email = 'your-admin-email';
|
-- - To create first admin: UPDATE users SET role = 'admin' WHERE email = 'your-admin-email';
|
||||||
-- - Only admins can manage folders and ebook metadata
|
-- - Only admins can manage folders and ebook metadata (enforced at application level)
|
||||||
|
-- - user_ebook_folders table admin-only access is enforced by AdminMiddleware in handlers
|
||||||
Reference in New Issue
Block a user