Skip to content

fix(plugins): stop hiding the postgres database from the database list - #1969

Merged
datlechin merged 1 commit into
mainfrom
worktree-fix-1967-postgres-database-hidden
Jul 27, 2026
Merged

fix(plugins): stop hiding the postgres database from the database list#1969
datlechin merged 1 commit into
mainfrom
worktree-fix-1967-postgres-database-hidden

Conversation

@datlechin

Copy link
Copy Markdown
Member

Fixes #1967.

Problem

The postgres database never appeared in any database list: sidebar tree, Cmd+K quick switcher, the database switcher popover, the database filter popover, the per-tab container picker, and the Backup and Restore Dump sheets.

Root cause

postgres was classified as a system database, and system databases are filtered out unconditionally with no toggle:

  • PostgreSQLPlugin.systemDatabaseNames = ["postgres", "template0", "template1"]
  • DatabaseTreeVisibility.visible drops anything flagged system.

The classification is wrong. PostgreSQL's docs are explicit: postgres is "a default database meant for use by users, utilities and third party applications", "simply a copy of template1 and can be dropped and recreated if necessary". Only template0 and template1 are the standard system databases, and both carry datistemplate = true, which fetchDatabases() already excludes with WHERE datistemplate = false.

So the list had exactly one effective entry: postgres. Its entire net effect was hiding the one database it should never hide. Supabase, Neon, and the default Docker image all put user data there.

The same mistake sat in the sibling drivers in that plugin: CockroachDB marked postgres and defaultdb (ordinary convenience databases) as system, Redshift marked dev (created with every cluster) as system.

Secondary defect

isSystemDatabase was computed from three hardcoded literal lists that disagreed. Redshift proved the drift was live: the registry default said ["postgres", "template0", "template1"] while RedshiftPluginDriver.fetchAllDatabaseMetadata said ["dev", "padb_harvest"], so opening Cmd+K on Redshift hid postgres for a moment, then swapped to hiding dev.

What changed

Classification. New PostgreSQLSystemDatabases holds one set per engine and replaces all six literals: PostgreSQL and PGlite [], CockroachDB ["system"], Redshift ["padb_harvest"]. The registry's curated defaults now match.

A database you are connected to is never hidden. DatabaseTreeVisibility.visible takes an activeDatabase and keeps it in the list even when it is a system database or the filter excludes it. MainEditorContentView already hand-rolled this for the per-tab picker only; that copy is gone and the five call sites share one rule. This also covers MSSQL, where a blank Database field lands you on master and the sidebar then omitted it.

Consequence worth knowing

Drop Database… in the switcher context menu is hidden for system databases, so postgres is now droppable (still blocked while you are connected to it). That matches psql and pgAdmin, and PostgreSQL's own docs say it can be dropped and recreated.

Tests

  • PostgreSQLSystemDatabasesTests: postgres, dev, defaultdb are not system; system and padb_harvest are.
  • PluginMetadataRegistrySystemDatabaseTests: the registry's curated defaults match the plugin's sets, so the two sources cannot drift again, plus a check that no PostgreSQL-family engine hides its default landing database.
  • DatabaseTreeVisibilityTests: the active database survives both the system filter and a non-matching selection, keeps its position, and an empty name is treated as absent.

18 tests pass. swiftlint lint --strict is clean. No PluginKit change, so no ABI bump; PostgreSQL is a bundled plugin, so nothing to publish to the registry.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@mintlify

mintlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟢 Ready View Preview Jul 27, 2026, 9:51 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@datlechin
datlechin merged commit 9ff15b8 into main Jul 27, 2026
3 checks passed
@datlechin
datlechin deleted the worktree-fix-1967-postgres-database-hidden branch July 27, 2026 09:55
@mintlify

mintlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟡 Building Jul 27, 2026, 9:50 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"postgres" database never shows in the database list

1 participant