Skip to content

Phase 2.1: Sequence management #25

Description

@aesslinger

Part of the Phase 2 set of PostgreSQL-specific features beyond the built-in driver.

Problem

Sequences are fundamental to PostgreSQL — every SERIAL/BIGSERIAL column creates one — but they're currently invisible in Tabularis. Users who need to inspect a sequence's current value, reset it after a bulk import, or change its increment must drop out to raw SQL; there's no browsable representation of sequences anywhere in the UI.

Proposed approach

Add RPC methods for the sequence lifecycle, backed by pg_sequences and standard DDL:

Operation SQL
List sequences SELECT * FROM pg_sequences WHERE schemaname = $1
Get sequence details SELECT * FROM pg_sequences WHERE sequencename = $1
Get current value SELECT currval('schema.seq') or last_value from pg_sequences
Reset sequence ALTER SEQUENCE schema.seq RESTART WITH $1
Set sequence value SELECT setval('schema.seq', $1)
Create sequence CREATE SEQUENCE schema.seq [INCREMENT BY ...] [START WITH ...]
Drop sequence DROP SEQUENCE schema.seq

Frontend integration

Sequences appear in the sidebar under a "Sequences" node, at the same level as Tables/Views/Routines. Double-click opens a detail panel showing increment, min/max, start, and current value.

Security considerations

Resetting a sequence can disrupt application logic (e.g. primary-key collisions if reset below the current max row id). The frontend should show a confirmation dialog before executing a reset, not fire it on a single click.

Acceptance criteria

  • List, inspect, create, alter, reset, and drop sequences work end-to-end against a live database
  • Sequences are browsable from the sidebar, matching the Tables/Views/Routines pattern
  • Reset requires explicit user confirmation in the frontend
  • No regressions in existing Phase 1 parity tests

Tests

  • test_get_sequences — lists all sequences in schema
  • test_get_sequence_details — returns increment, min, max, start, current
  • test_reset_sequence — verify value changes
  • test_create_and_drop_sequence — lifecycle

References

  • Full spec: docs/planning/03-phase-2-issue-16.md (2.1)
  • Priority: Sprint 1 — high demand, straightforward
  • Ships as: beta update as soon as this lands (no need to wait for the rest of Phase 2)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions