Created_at column for PostgreSaver checkpointer

Hi. I am using PostgresSaver checkpointer to add memory to my agent. I am using the checkpointer in my code and have setup the tables required for the checkpointer using drizzle ORM. Everything is working fine but I also wanted a created_at column for the checkpoints, or at least for a thread. I want to know when the chats were started, at what date and time.

Is there a way to change the schema of the checkpointer? Is it too complicated?

One thing I have in my mind is to create a new table that stores the creation data and time, and that table would have a reference to the checkpoints table. Correct me if I am wrong.

Thanks.

hi @mehdi1514

I think the timestamp of every checkpoint is already tracked - it’s just stored inside the JSONB checkpoint column rather than as a dedicated SQL column.

// getStateHistory returns checkpoints in descending order (newest first)
let threadCreatedAt: string | undefined;
for await (const snapshot of graph.getStateHistory(config)) {
  threadCreatedAt = snapshot.createdAt;  // keep overwriting — last one is the oldest
}

or

-- Get the creation time of a specific thread
SELECT
  thread_id,
  checkpoint->>'ts' AS created_at
FROM checkpoints
WHERE thread_id = 'my-thread-123'
  AND checkpoint_ns = ''
ORDER BY checkpoint_id ASC
LIMIT 1;
-- List all threads with their creation timestamps
SELECT DISTINCT ON (thread_id)
  thread_id,
  checkpoint->>'ts' AS created_at
FROM checkpoints
WHERE checkpoint_ns = ''
ORDER BY thread_id, checkpoint_id ASC;

or add a created_at column yourself

-- Safe to run — PostgresSaver won't touch this column
ALTER TABLE checkpoints
ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW();