From 7586b2e4f52b184d590f62da8241a3938e521472 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Wed, 21 Oct 2026 20:03:44 +0700 Subject: [PATCH] docs(features): edit the schema from the ER diagram --- features/er-diagram.mdx | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/features/er-diagram.mdx b/features/er-diagram.mdx index d867be5..02360d6 100644 --- a/features/er-diagram.mdx +++ b/features/er-diagram.mdx @@ -18,7 +18,7 @@ Right-click the empty space below the sidebar’s object list and choose **View /> -The diagram is a snapshot taken when the tab opens, and it does not follow later schema changes. After a migration, close the tab and open it again. +After a change made elsewhere, click **Refresh** in the diagram's toolbar or press `Cmd+R`. Every table stays where it is, and a table that is new since the last load is placed to the right of the others. ## Reading the diagram @@ -56,7 +56,36 @@ Drag a node to move it, toward the edge of the viewport to auto-scroll. Position VoiceOver reads the diagram as a layout area of tables. Each table announces its name, its column count and what it is joined to; step into one to hear each column with its type and whether it is a primary key, a foreign key, or optional. Selecting a table in the diagram moves the VoiceOver cursor -to it. +to it. `VO-Shift-M` on a table or a column opens its menu. + +## Editing the schema + +Right-click a table, a column, a relationship or the empty canvas for what applies there. Double-click a table to open its rows in a new tab. + +| Target | Menu | +|--------|------| +| Table | **Open Table**, **Show Structure**, **Add Column…**, **Copy Name** | +| Column | **Add Foreign Key…**, **Rename Column…**, **Add Column…**, **Open Table**, **Show Structure**, then **Delete Foreign Key** for a key on the column and **Delete Column** | +| Relationship | **Show Structure of** the table that holds the key, **Delete Foreign Key** | +| Empty canvas | **New Table…**, **Refresh** | + +To add a foreign key, hover over the column that will hold it, drag from the dot on the table's right edge, and drop on the column it references. A sheet confirms the columns, the constraint name and the `ON DELETE` and `ON UPDATE` actions. **Add Foreign Key…** in a column's menu opens the same sheet without the drag. + +To drop a foreign key, click its relationship line and press `Delete`. + +**New Table…** opens a [Create Table](/features/table-structure#creating-a-new-table) tab on the diagram's database and schema. Once the table is created, it appears in the diagram where you right-clicked. + +## Saving diagram edits + +Nothing runs until you save. A key you add or drop is drawn dashed, red when dropped. A column you add is tinted green, a dropped one red and struck through, a renamed one yellow. + +- **Preview SQL** (`Cmd+Shift+P`) shows the statements, the same ones the table's [Structure tab](/features/table-structure#saving-changes) builds for the same change. +- **Save Changes** (`Cmd+S`) applies them one table at a time, in the order you first edited them, then reloads the diagram with every table in place. Each table's save asks the way a Structure tab save does under [Safe Mode](/features/safe-mode), and on SQLite a key change is shown as a table rebuild to confirm first. +- `Cmd+Z` undoes the last edit. **Discard Changes** in the diagram's toolbar drops all of them. + +Closing the tab or the window with edits staged asks to save them first. + +An item an engine cannot carry out is left out of the menu: on an engine that cannot add or remove foreign keys, the key items and the drag handle do not appear. ## Compact mode