Skip to content

feat(linux): show a schema as an ER diagram - #3817

Merged
datlechin merged 4 commits into
mainfrom
feat/3670-linux-er-diagram
Oct 23, 2026
Merged

datlechin merged 4 commits into
mainfrom
feat/3670-linux-er-diagram

Conversation

@datlechin

@datlechin datlechin commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Show ER Diagram, in a table's or view's sidebar menu and on each schema's heading, opens the schema in a tab of its own. A second Show brings that tab forward. A key-value engine's keys offer no diagram.
  • Tables are cards of their columns with PK and FK badges; foreign keys are lines between the rows they join, in crow's foot notation (nullable and unique keys drawn as such). Keys to other schemas are not drawn.
  • The tables are read in the background, two at a time on one lease each (columns, foreign keys, indexes), with progress and Stop. A refresh keeps the diagram up, shows its progress in the bottom bar and turns Refresh into Stop. A failed refresh keeps the diagram under a Retry banner; a schema change shows a Refresh banner.
  • Automatic layout: referenced tables left of the tables that hold their keys, barycenter ordering, long columns wrapped, lone tables in a grid.
  • Pan (drag empty space, middle drag, scroll), zoom (buttons, Ctrl+plus/minus/0, f for Best Fit, Ctrl+scroll, pinch), drag tables, Reset Layout. Moved tables keep their place through a refresh, a reopen (Ctrl+Shift+T) and a restart.
  • Click selects a table and highlights its keys at both ends; double click or Enter opens it in a table tab; the menu (right click, Menu, Shift+F10) offers Open Table and Show Structure.
  • Export as PNG (2x, capped) or SVG, drawn through the same render nodes as the screen. The file is written through the workspace's export ledger: Stop in the operations popover, the close prompt, the logout inhibitor and an "Exported" toast with Show in Files.
  • Keyboard and screen reader: the canvas is a list and each table a focusable list item with its name, position and a description of its columns and the tables it joins. Tab and the arrow keys move between tables, Alt+arrows move one, the focus selects it. Hidden controls hand the focus on, and a drawn diagram is announced.
  • Colours come from the theme (libadwaita colour variables read through hidden probes, the accent colour), so light, dark and high contrast follow the desktop.
  • Enables cairo-rs's png and svg features; no new crate.
  • Workspace file version 2 (Diagram tab records with moved places); version 1 reads unchanged through an identity step, with a workspace-v2.json golden fixture that holds every tab kind.
  • New "ER Diagram" section in the shortcuts dialog; ROADMAP and ARCHITECTURE updated.

Test plan

  • Unit: model (keys, other schemas, uniqueness, nullability), layout (no overlap, direction, cycles, 500 tables), scene routing and hits, zoom, palette, export PNG and SVG, places budget, records round trip.
  • Widget: every table named and focusable, focus selects and Enter opens, keyboard moves kept through a refresh, zoom, Stop, a failed refresh keeps the diagram, the empty schema, 500 tables in bounded time, the bar within the 360 px window floor while refreshing, no diagram offered for a key-value engine's keys; workspace: one tab per schema, sidebar menu and heading, Open Table and Show Structure, restore and reopen with places, schema change banner, theme colours.
  • Updated on purpose: the_new_table_button_follows_the_dialect finds the New Table button by its action, since the schema heading now has two buttons; unsupported_version_blocks_key seeds version 3, since 2 is now current.
  • Real engines (requires docker): a 50-table schema with 54 keys on PostgreSQL, MySQL, MariaDB and SQL Server; SQLite in the unit suite.

Screenshots

After, light: orders selected, its keys highlighted

After, dark

Sidebar menu, light

Sidebar menu, dark

Diagram menu, light

Diagram menu, dark

Shortcuts, light

Shortcuts, dark

Fixes #3670

…agram

# Conflicts:
#	linux/crates/app/src/application/accelerators.rs
#	linux/crates/app/src/application/shortcut_owner.rs
#	linux/crates/app/src/ui/tab_load/load_failure.rs
#	linux/crates/app/src/ui/workspace/close_flow.rs
#	linux/crates/app/src/ui/workspace/mod.rs
#	linux/crates/app/src/ui/workspace/sidebar/sidebar_menu.rs
#	linux/crates/app/src/ui/workspace/tab_factory.rs
#	linux/crates/app/src/ui/workspace/tab_identity.rs
#	linux/crates/app/src/ui/workspace/tab_spec.rs
#	linux/crates/app/src/ui/workspace/tests/mod.rs
#	linux/crates/app/src/ui/workspace/window_tabs.rs
#	linux/crates/app/src/ui/workspace/workspace_persistence.rs
#	linux/crates/app/src/ui/workspace/workspace_tabs.rs
#	linux/po/POTFILES.in
@datlechin
datlechin enabled auto-merge (squash) October 23, 2026 16:57
@datlechin
datlechin merged commit f337cf6 into main Oct 23, 2026
38 checks passed
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.

ER diagram for the Linux app

1 participant