In what table are bookmarks stored, if not “bookmarks”?

AI-generated summary

In a discussion about where bookmarks are stored in Discourse, Mark_Schmucker reports that querying the bookmarks table returns no results, even after adding a bookmark. Mittineague suggests checking the count of records, but Mark_Schmucker confirms visually that bookmarks exist. Mittineague expresses confusion, expecting at least one result. Finally, simon clarifies that the bookmarks table is not yet in active use — it’s part of upcoming improvements. Instead, current bookmark data can be queried via the post_actions table, joining with posts and topics, filtering by post_action_type_id = 1 (which represents bookmarks), and excluding deleted records. A sample SQL query is provided to retrieve user-topic bookmark counts. This highlights that while the bookmarks table exists in schema, it’s not yet populated — bookmark data remains in legacy structures until the new system is fully implemented.

I want to see everyone’s bookmarks. So I try this simple query in Data Explorer.

SELECT * from bookmarks

That returns no results. I added a bookmark of my own and ran it again. Still no results. Where are bookmarks stored, if not in the bookmarks table?

Try running

SELECT COUNT(id) FROM bookmarks 

image


One of my bookmarks. I’m sure others have bookmarks also:
image

Sorry, I’m at a loss for what the problem might be. That makes no sense to me at all. I would think you would get some kind of error message or at least the 1 you know exists.

The bookmarks table doesn’t seem to be getting used yet. It is part of some improvements that are being made to Discourse’s bookmarking functionality.

Currenty, you can get information about bookmarks with a query like this:

SELECT
t.user_id,
t.id AS topic_id,
COUNT(*) AS bookmark_count
FROM post_actions pa
JOIN posts p
ON p.id = pa.post_id
JOIN topics t
ON t.id = p.topic_id
WHERE pa.post_action_type_id = 1
AND t.deleted_at IS NULL
AND p.deleted_at IS NULL
GROUP BY t.id, t.user_id
ORDER BY bookmark_count DESC
LIMIT 20