yida-db-seq-fix

Detect and auto-correct PostgreSQL sequence start values to prevent primary key conflicts.

201|43|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/openyida/openyida --skill yida-db-seq-fix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: yida-db-seq-fix
Source: https://github.com/openyida/openyida/tree/main/yida-skills/skills/yida-db-seq-fix
Command: npx skills add https://github.com/openyida/openyida --skill yida-db-seq-fix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL Sequence 自动修复工具。检测宜搭环境自动建表时 Sequence 的起始值是否合理,若存在与当前最大 ID 不一致的情况,提供安全的 dry-run 预览和自动修复,将起始值调整为 max(id) + 1,从而避免插入时产生主键冲突。

Core Features & Use Cases

  • Sequence 值自检与对比:检测核心表的当前序列值与表中最大 ID,判断是否需要修复。
  • 安全修复流程:先 dry-run 预览,确认影响范围,再执行修复并验证结果。
  • 审计与回溯:将修复操作记录到日志,便于问题追踪和追溯。

Quick Start

在开发环境下执行 openyida db-seq-fix --dry-run 来预览影响,然后再执行 openyida db-seq-fix --fix 进行修复并验证结果。

Frequently Asked Questions about yida-db-seq-fix

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does PostgreSQL primary key conflict occur after data migration or import?

PostgreSQL primary key conflicts occur after data migration when sequences fall behind the maximum existing ID values, causing new inserts to generate duplicate keys instead of continuing from the correct auto-increment position.

How do I fix PostgreSQL sequence start values to prevent primary key conflicts?

To fix PostgreSQL sequence start values, run a dry-run preview to detect inconsistencies across core tables, then execute the repair command to patch sequences to max(id)+1 and verify the corrected results safely.

What is a dry-run preview for database sequence auto-correction and when do I need it?

A dry-run preview for database sequence auto-correction is a mandatory safety check that displays the impact range of adjusting sequence starts to max(id)+1 before applying any changes, preventing unintended data modifications.

Do I need a PostgreSQL connection to run sequence detection and repair on core tables?

Yes, you need an active PostgreSQL connection with access to the target database to detect current sequence values, compare them against maximum IDs in core tables, and execute the required sequence start value patches.

Which database tables are affected by sequence value auto-correction during environment automatic table creation?

Sequence value auto-correction targets core tables including form_component, form_definition, form_instance, form_permission, process_definition, process_instance, process_task, and system_log to ensure consistent primary key generation.

Can I trace and audit PostgreSQL sequence fixes after applying them to the database?

Yes, you can trace and audit PostgreSQL sequence fixes because the repair process logs all operations during the correction workflow, providing full traceability for tracking sequence adjustments and problem resolution.