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:
2026-01-27 16:36:04 -05:00
parent ad64c044a7
commit cf51644f44
+4 -5
View File
@@ -68,10 +68,8 @@ CREATE TABLE user_ebook_folders (
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
folder_path VARCHAR(500) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
UNIQUE(user_id, folder_path),
CONSTRAINT admin_only_folder CHECK (EXISTS (
SELECT 1 FROM users WHERE id = user_id AND role = 'admin'
))
UNIQUE(user_id, folder_path)
-- Note: Admin-only access is enforced at application level in handlers/auth.go
);
-- 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
-- - 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';
-- - 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