Skip to content

List PostgreSQL sequences in the sidebar and edit them #3605

Closed

Description

@datlechin

Problem

A PostgreSQL sequence cannot be found or changed from the sidebar. The sidebar has no sequence kind (apple/TablePro/Models/Sidebar/SidebarObjectKind.swift:18-26), and the PostgreSQL table list reads relation kinds r, p, v, m and f only, never S (apple/Plugins/PostgreSQLDriverPlugin/PostgreSQLTableListing.swift:51-55).

The driver already reads sequences: fetchSequences (apple/Plugins/PostgreSQLDriverPlugin/PostgreSQLPluginDriver+Sequences.swift:18) feeds SQL export (features/import-export.mdx:38) and the CREATE SEQUENCE lines the DDL tab prepends (features/table-structure.mdx:247). The user never sees that list.

So checking why an insert fails on a duplicate key after a bulk load, or resetting a sequence after a restore, means writing SELECT last_value FROM ... and SELECT setval(...) by hand. MariaDB sequences already show in the sidebar (features/table-operations.mdx:114-116).

Proposed solution

  • A Sequences section under each schema, beside Types, one row per sequence, with the owning column (OWNED BY) shown on hover.
  • Opening a sequence shows its CREATE SEQUENCE statement and its properties: data type, start, increment, minimum, maximum, cache, cycle, last value and owner.
  • Set Next Value… writes SELECT setval(...), offering the owning column's current max() as the value.
  • Edit Sequence changes increment, minimum, maximum, cache and cycle through ALTER SEQUENCE, and Rename, Drop (with Cascade) and New Sequence… cover the rest.
  • Every change shows its SQL before it runs and goes through Safe Mode like any other structure change.
  • The sidebar filter and Open Quickly find sequences by name.

Done when: on PostgreSQL 13 to 18, a schema's sequences are listed, a sequence behind a SERIAL column shows that column as its owner, and Set Next Value fixes a sequence that fell behind its table.

Alternatives considered

Query pg_sequences and run setval or ALTER SEQUENCE in a query tab.

Platform

macOS

Related database type

PostgreSQL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions