seed-file-management

Reset PostgreSQL sequences after explicit-ID seed inserts.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/sage-base/sagebase --skill seed-file-management
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: seed-file-management
Source: https://github.com/sage-base/sagebase/tree/main/.claude/skills/seed-file-management
Command: npx skills add https://github.com/sage-base/sagebase --skill seed-file-management

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Seed data management in PostgreSQL often leads to sequence gaps when IDs are explicitly assigned. This skill defines guidelines to safely create, modify, and apply seed files while preventing sequence collisions.

Core Features & Use Cases

  • Sequence resets after explicit-ID inserts using COALESCE(MAX(id)) patterns to set the corresponding id sequence
  • Idempotent seeds via UPSERT patterns and conflict handling to allow re-running seed scripts safely
  • File structure & naming rules to keep seeds organized and deterministic

Quick Start

Run seed generation or apply seed updates with explicit IDs, and ensure the sequence is reset to max(id) + 1.

Frequently Asked Questions about seed-file-management

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

FAQPage Schema
Why do I get sequence gaps when inserting explicit IDs in PostgreSQL seed data?

Sequence gaps occur because manually inserting explicit IDs does not advance the underlying sequence. This skill solves sequence gaps by enforcing sequence resets using the COALESCE(MAX(id)) pattern after explicit-ID inserts.

How do I make PostgreSQL seed scripts idempotent for re-running safely?

You can make seed scripts idempotent by using UPSERT patterns and conflict handling. This enables safe re-runs of seed scripts by updating existing rows instead of duplicating data or causing constraint violations.

What is the best way to reset sequences after explicit-ID inserts in PostgreSQL?

The best way to reset sequences is applying a COALESCE(MAX(id)) pattern to set the sequence to max(id) + 1 after explicit-ID inserts, preventing future sequence collisions during subsequent data generation.

Can I use UPSERT patterns for deterministic initial data setup across database projects?

Yes, you can use UPSERT patterns for deterministic initial data setup. This skill supports UPSERT-based updates during seed generation and migrations to ensure reliable initial data management across database projects.

When do I need to reset sequences after inserting explicit IDs for seed data?

You need to reset sequences after inserting explicit IDs whenever you require deterministic IDs in seed data, migrations, or initial data setup to prevent sequence collisions and maintain database structural integrity.