Help › Change a database's structure

See how a schema changed over time

Keep snapshots of a schema's structure, see what changed between them and since last week, and compare a schema with how it was or with another environment.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

Schema history keeps snapshots of a schema's structure on this computer: its tables with their columns, keys, indexes, foreign keys and checks, and the definitions of its views, functions, procedures, sequences and triggers. From them it shows what changed and when, and how a schema drifted from how it was or from the same schema in another environment.

A snapshot holds structure only: never a row, a value or a password. That is why snapshots of Production schemas are kept like any other.

When snapshots are taken

Querlyn never reads a schema on its own just to take a snapshot. It keeps one when it has read the whole schema anyway, and when you ask:

WhenWhat is read
You choose Take Snapshot Now (Query › Take Snapshot Now)The schema whole, with a progress line. Stop (Command Palette › Database: Stop Taking the Snapshot) ends the reading.
Schema compare reads a schemaNothing more: what the comparison read is kept.
You refresh a schema that already has snapshots, or its database or connectionThe schema whole, if it has at most 300 tables. A larger schema is kept by Take Snapshot Now and schema compare only.

A snapshot is stored only when something changed since the schema's newest snapshot. Taking one of an unchanged schema says so and stores nothing.

Open a schema's history

Right-click a schema, database or connection in the sidebar and choose Show Schema History (Query › Show Schema History), or use Query › Show Schema History. On a table or another object, the history opens filtered by its name.

The tab lists the snapshots by time, newest first, each with why it was taken and what changed since the one before it. Select a snapshot to see what it changed. The list moves with ↑ on macOS or Up on Windows and Linux and ↓ on macOS or Down on Windows and Linux.

Beside the list, the changes are grouped:

GroupMeaning
AddedCreated since the earlier snapshot.
ChangedDefined differently.
DroppedGone since the earlier snapshot.

Select a change to see it in words (for example "Column total: type numeric(10,2) → numeric(12,2)") and its definition before and after, side by side, with the lines that differ marked.

Everything counts as a change here: whitespace in a view's definition, the order of columns, collations, comments and the names of constraints.

The Schema list at the top switches to another schema of the connection that has snapshots. The field beside it filters by object name: only the snapshots that changed such an object, and only its changes, are listed.

For more room, hide the list of snapshots with the chevron on its edge or Snapshots (Command Palette › Database: Toggle Snapshot List); the strip it leaves brings it back.

See what changed since a date

Changes Since shows everything that changed from an earlier snapshot to the newest, as one list:

ChoiceCompares the newest snapshot with
Command Palette › Database: Changes Since the Previous SnapshotThe one before it
Command Palette › Database: Changes Since YesterdayThe newest one taken before today
Command Palette › Database: Changes Since Last WeekThe newest one at least seven days old
Command Palette › Database: Changes Since Last MonthThe newest one at least thirty days old
Command Palette › Database: Changes Since the Selected SnapshotThe snapshot selected in the list: any date kept

When no snapshot is that old, the oldest one kept is used.

Renamed columns and tables

Snapshots match columns and tables by name, so a renamed column shows as one column dropped and another added. Where that looks like a rename (the same type in the same place, or similar names), the detail says so as a hint. Querlyn never assumes a rename.

Compare with another environment

Compare With… offers the same schema on your other connections of the same kind of database, for example staging, in one click. Choose Another Schema… (Command Palette › Database: Compare With Another Schema…) opens a comparison with this schema as the source and the target still to choose. Either is an ordinary schema compare, with its migration script.

Compare with how the schema was

Select a snapshot and choose Compare Now With Snapshot (Command Palette › Database: Compare Now With Snapshot). It opens a schema comparison of the schema as it is now (the source) with the snapshot (the target), read from this computer:

  • The list shows what changed since the snapshot.
  • The script turns the schema as it was then into the schema now, ready to copy or save for another environment that is still as it was.
  • Swap makes the schema now the target: the script then brings it back to how it was in the snapshot, and Apply to Target can run it, with the usual questions on Production.

A snapshot is never changed: Querlyn never applies a script to it.

When a refresh finds changes

When a refresh of a schema finds that it changed since its newest snapshot, the status bar says so, for example "public on Shop: 3 changes since yesterday". Select it to open the history at that snapshot (Command Palette › Database: Show Schema Changes), or dismiss it with its close button. It asks nothing and stays until then.

Clear the history

Clear Schema History… (Command Palette › Database: Clear Schema History…) removes snapshots from this computer after asking. In the Schema History tab and on a schema it clears that schema's; on a connection it clears every schema's of that connection. Deleting a connection removes its snapshots too. The databases themselves are not changed.

What is kept, and where

  • On this computer only, in Querlyn's own database. Snapshots are not synced and are not shared with a team.
  • Bounded. Each schema keeps its newest 100 snapshots, for a year. Its newest snapshot always stays, however old, because the next one is compared with it. An object that did not change between snapshots is stored once.
  • Screen-share mode hides database names in the tab as elsewhere; the definitions are shown, as they are in schema compare.

Help for Querlyn 0.1.0. All help topics