16 lines
654 B
SQL
16 lines
654 B
SQL
-- Create user_bookmarks table for students to save lessons
|
|
CREATE TABLE IF NOT EXISTS user_bookmarks (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
organization_id UUID NOT NULL,
|
|
user_id UUID NOT NULL,
|
|
course_id UUID NOT NULL,
|
|
lesson_id UUID NOT NULL,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
UNIQUE(user_id, lesson_id)
|
|
);
|
|
|
|
-- Index for efficient querying
|
|
CREATE INDEX IF NOT EXISTS idx_user_bookmarks_user_id ON user_bookmarks(user_id);
|
|
CREATE INDEX IF NOT EXISTS idx_user_bookmarks_course_id ON user_bookmarks(course_id);
|
|
CREATE INDEX IF NOT EXISTS idx_user_bookmarks_org_id ON user_bookmarks(organization_id);
|