Skip to content

feat(dashboard): add database extensions page - #5116

Merged
dbm03 merged 4 commits into
mainfrom
feat/dashboard-database-extensions
Nov 19, 2026
Merged

dbm03 merged 4 commits into
mainfrom
feat/dashboard-database-extensions

Conversation

@dbm03

@dbm03 dbm03 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Resolves #4841

Checklist

  • No breaking changes
  • Tests pass
  • New features have new tests
  • Documentation is updated (if applicable)
  • Title of the PR is in the correct format (see below)

Goal

The dashboard had no way to see or manage the PostgreSQL extensions in a project database. To enable pgvector, postgis, pg_cron or similar extensions, users had to write CREATE EXTENSION by hand in the SQL editor, and on local CLI projects that SQL left no migration behind. Extensions that need a library in shared_preload_libraries also failed until users found and changed that setting themselves.

This branch adds a Database → Extensions page for each data source. It lists every available extension, installs and uninstalls them after the user reviews (and optionally edits) the generated SQL, walks through preloading a library when an extension needs one, and warns about installed extensions whose library Postgres does not preload. On the Nhost platform the SQL runs directly through Hasura /v2/query; on local CLI projects each change is recorded as a replayable Hasura migration with an up and a down step. Existing navigation and database pages keep working, and the extensions docs now match the preload behaviour.

Type: Enhancement

Changes

  • Route and navigation — A new page database/extensions/[dataSourceSlug] renders DatabaseExtensions inside RetryableErrorBoundary, ProjectScope and DatabaseArea, like the other database pages. It appears as an Extensions tab between SQL Console and Backups, and as a command palette entry with the keywords postgres, pgvector and postgis. The route is listed in projectStatePages so it is gated on a running project, and getProjectFeaturePagePath maps /database/extensions to /database/extensions/default so switching projects keeps the page open.
  • Extension catalog — usePostgresExtensionsQuery sends one read-only run_sql bulk request to /v2/query. The SQL joins pg_available_extensions with pg_available_extension_versions on the default version to get each extension's requires list, and returns one JSON row per extension. An unparseable row raises "Received an invalid extensions catalog."; an HTTP error is normalized and, on the first load, rethrown to the page's error boundary. A failed refresh keeps the loaded list, because refreshes fail while Postgres restarts.
  • Page layout — "Popular extensions" cards (vector, postgis, pg_cron, uuid-ossp) sit above an "All extensions" table. The search matches name, comment and display name (vector is shown as pgvector). An All / Installed / Available single-select toggle group filters the table, and its counts follow the search. Each extension has a docs icon link named after it, its version (vX: the installed version, or the default version when not installed), an Installed badge, and an Install or Uninstall button. Installed plpgsql, pgcrypto and citext show a locked "Built-in" marker with the reason, readable by screen readers, instead of Uninstall. A search without matches shows a short message under the heading.
  • SQL builders — getInstallExtensionSQL produces CREATE EXTENSION IF NOT EXISTS <name> for the default version, with CASCADE when the extension has dependencies; the install dialog lists the not-yet-installed dependencies that CASCADE adds, computed transitively by getMissingExtensionDependencies. getUninstallExtensionSQL produces DROP EXTENSION IF EXISTS <name> without CASCADE, except for pg_durable, which cannot be dropped otherwise. Names are quoted with node-pg-format, and withPostgresRole prefixes every statement with SET LOCAL ROLE postgres;, so the role ends with the transaction on a pooled connection even if the user edits the SQL.
  • Transport — useSetExtensionInstalledMutation builds a migration with buildExtensionMigration: the up step is the reviewed SQL verbatim; the down step is the generated reverse statement. On the platform it posts the up step as a run_sql bulk request to /v2/query. Locally it posts the full migration, named create_extension_<name> or drop_extension_<name>, to the CLI migrations API. Success shows a toast. On success and on error it invalidates the extensions, functions and data-source queries, because a slow install can time out after Postgres committed.
  • Install and uninstall dialogs — Each open remounts the dialog, so it starts with freshly generated SQL and no error. The SQL sits in a CodeMirror editor that keyboard users can reach and leave with Tab. The editor has no Tab indentation, autocomplete or search popup, because the dialog handles Escape first: closing a popup with Escape would close the dialog and drop the edits. A dialog cannot be dismissed while its request runs, closes only on success, shows the Postgres error inline otherwise, and returns focus to the button that opened it, or to the All extensions heading when that button is gone. The uninstall dialog explains, before running, that the plain DROP fails while objects depend on the extension and that CASCADE also drops those objects and their data. For pg_durable it warns that its workflow state is deleted and, on the platform, links to the point-in-time recovery settings.
  • Preloaded libraries — PRELOAD_LIBRARY_EXTENSIONS mirrors the PostgresPreloadLibrary values of nhost.toml (the default sharedPreloadLibraries plus pg_durable and pg_ivm). usePreloadedLibrariesQuery reads current_setting('shared_preload_libraries') from the running server as postgres, split into one row per library in SQL, and usePreloadLibrary compares it with the configured postgres.settings.sharedPreloadLibraries (an unset list means the defaults). It derives a status: preloaded, not-configured, restarting or restart-failed on the platform, pending-local-restart locally, plus loading and error. Adding the library rewrites the full configured list with the library appended, refetches the configuration and, on the platform, the project state; while the project is live and still restarting, it polls the running server every 10 seconds.
  • Preload flows — For these extensions the install dialog has two steps: add the library, then install. Install and the SQL editor stay disabled until Postgres loads the library; a live region announces each status change. Locally the step asks the user to run nhost up, then check again. An installed extension whose library is not preloaded gets a warning icon whose popover opens a Preload dialog with the same step, and the page shows an alert naming every such extension.
  • Docs — The extensions guide now tells users to preload pg_search and pg_durable before installing them.
  • Tests — A page-level Vitest/MSW suite whose mocked write endpoints apply the change to the mocked catalog. It covers listing, search, filters, built-in locking, error-boundary propagation, a failed catalog refresh, the local install migration with edited SQL, fresh SQL on every open, dependency CASCADE, the preload flows (local, platform restart, errors while adding the library, deploy failure, settings failure), the not-preloaded warning, uninstall on the platform, the dependent-objects error and pg_durable. Unit tests cover the SQL and migration builders and getMissingExtensionDependencies.

Flow

flowchart LR
  Page[DatabaseExtensions] -->|read-only run_sql| V2[Hasura /v2/query]
  Page --> Dlg[Install / Uninstall / Preload dialog]
  Dlg -->|needs a preloaded library| Pre[usePreloadLibrary]
  Pre -->|sharedPreloadLibraries| Config[Project config]
  Pre -->|shared_preload_libraries| V2
  Dlg --> Mut[useSetExtensionInstalledMutation]
  Mut -->|platform| V2
  Mut -->|local CLI: up + down migration| Migrate[CLI migrations API]
  Mut -->|on settle| Inv[invalidate extensions, functions, data source queries]
Loading

Key files

  • dashboard/src/features/orgs/projects/database/extensions/hooks/ (+444/-0) — catalog and preloaded-libraries queries, the preload status and config update, and the install/uninstall transport.
  • dashboard/src/features/orgs/projects/database/extensions/utils/ (+107/-0) — SQL builders, withPostgresRole, dependency resolution, display names, docs URLs, built-in and missing-preload checks.
  • dashboard/src/features/orgs/projects/database/extensions/constants.ts and gql/ (+51/-0) — popular, preload-required, built-in and CASCADE-on-uninstall extensions; the configured-libraries query.
  • dashboard/src/features/orgs/projects/database/extensions/components/ (+1500/-0) — the page, cards, table, action control, preload status, alert, SQL editor, install fields, and the install, preload and uninstall dialogs.
  • Tests (+959/-0) — DatabaseExtensions.test.tsx page suite plus unit tests next to the hooks and utils.
  • dashboard/src/pages/orgs/[orgSlug]/projects/[appSubdomain]/database/extensions/[dataSourceSlug].tsx (+30/-0) — route and layout.
  • Navigation (+11/-0) — DatabaseRouteTabs.tsx, command-palette/catalog.tsx and tree.tsx, projectStatePages.ts, getProjectFeaturePagePath.ts.
  • dashboard/src/utils/__generated__/graphql.ts (+63/-0) — generated hook for GetConfiguredPreloadLibraries.
  • docs/src/content/docs/products/database/extensions.mdx (+3/-3) — preload guidance.

@dbm03 dbm03 self-assigned this Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Vercel Deployment Info - dashboard

@dbm03
dbm03 force-pushed the feat/dashboard-database-extensions branch from e1ed56f to 0b13c49 Compare October 8, 2026 17:03
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Vercel Deployment Info - docs

@dbm03
dbm03 force-pushed the feat/dashboard-database-extensions branch 3 times, most recently from f2dee5e to 0c7c414 Compare October 23, 2026 13:24
@dbm03
dbm03 force-pushed the feat/dashboard-database-extensions branch 2 times, most recently from 98282a6 to 5fb101b Compare November 11, 2026 22:26
@dbm03
dbm03 force-pushed the feat/dashboard-database-extensions branch from 5fb101b to 1325e16 Compare November 11, 2026 22:28
@dbm03
dbm03 marked this pull request as ready for review November 11, 2026 22:30
@dbm03
dbm03 enabled auto-merge (squash) November 19, 2026 08:54
@dbm03
dbm03 disabled auto-merge November 19, 2026 09:18
@dbm03
dbm03 merged commit db20a36 into main Nov 19, 2026
22 checks passed
@dbm03
dbm03 deleted the feat/dashboard-database-extensions branch November 19, 2026 09:48
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.

dashboard: add extensions page to the database

2 participants