CREATE TABLE favorites ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, folder_id UUID NOT NULL REFERENCES folders(id) ON DELETE CASCADE, position INTEGER NOT NULL DEFAULT 0, is_expanded BOOLEAN NOT NULL DEFAULT false, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), UNIQUE (user_id, folder_id) ); CREATE INDEX idx_favorites_user ON favorites(user_id);