check_sequences
Identify sequences that lag behind their column's maximum value after migrations or bulk copies, revealing stale sequences that could issue duplicate IDs.
Instructions
Find sequences lagging behind their column's max value (stale after migrations).
A behind: true sequence would hand out an id that already exists — fix with
setval(). Run this after any bulk copy or logical-replication migration. By
default only the problem sequences are listed, with total_sequences reporting
how many were checked — so behind_count: 0 means "all clear". Pass
behind_only=false for the full census; on a large schema that is one row per
sequence (hundreds), so ask for it only when you need every sequence's state.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>"
},
"name": "check_sequences"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | ||
| behind_only | No |