Help › Change a database's structure
See applied and pending migrations
See which migrations a schema has applied, which your project still holds, which failed, and which files changed since they ran, for ten migration tools.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
The Migrations tab shows what a migration tool has done to a schema: which migrations it applied, in what order, when and by whom, which one failed or did not finish, and whether its lock is held. Link the project's folder and it also shows the migrations still to come, their SQL, and the lock warnings Querlyn finds in them before you deploy.
Querlyn only reads. It never writes to a migration tool's tables, never runs a migration tool and never runs a migration by itself. Migration files are read as text; Python, Ruby, JavaScript and Elixir files are never run. You can open a pending migration's SQL in a query tab and run it yourself; see Open a pending migration in the editor.
Which tools Querlyn knows
Querlyn looks for the tables each tool creates under its default name, and then checks their columns, so a table of your own with one of these names is not taken for a tool's:
| Tool | Table it reads | What it records |
|---|---|---|
| Flyway | flyway_schema_history (schema_version before Flyway 5) | Every migration: version, description, script, who, when, how long, checksum, success |
| Liquibase | databasechangelog, and its lock databasechangeloglock | Every changeset: ID, author, changelog, when, how it ran, checksum; who holds the lock |
| Alembic | alembic_version | Only the current revision |
| Rails | schema_migrations with a text version, and ar_internal_metadata | The versions applied, and the environment |
| Django | django_migrations | Every migration: app, name, when |
| Prisma | _prisma_migrations | Every migration: name, checksum, started, finished, rolled back, the log of a failure |
| golang-migrate | schema_migrations with version and dirty | Only the current version, and whether it is dirty |
| Sqitch | changes in the sqitch schema | Every change deployed: project, name, note, who, when |
| Knex | knex_migrations, and its lock knex_migrations_lock | Every migration: file name, batch, when; whether the lock is held |
| Ecto | schema_migrations with version and inserted_at | The versions applied, and when |
History tables under other names
A tool can be told to keep its history under another name: Flyway's
table setting, Liquibase's databaseChangeLogTableName and
databaseChangeLogLockTableName, Knex's tableName, golang-migrate's
x-migrations-table, Alembic's version_table. Querlyn finds such a
table when the connection names it:
- Select the connection and choose .
- In Migration history tables, near the end of the dialog, type the
table's name. Separate several names with commas. Write
schema.tableto mean the table in one schema only; a name alone counts in every schema. Upper and lower case do not matter. - Choose Save, then the connection in the sidebar, so that the schema gets its Migrations row.
The table's columns still decide which tool it belongs to, so a named
table that is no tool's is left alone. The names are saved with the
connection. Sqitch's registry is found only in a schema named sqitch.
Open a schema's migrations
When the sidebar lists a schema that has one of these tables, it shows a Migrations row under it (for a file database such as SQLite, under the connection). Double-click it, or select it and press ↩ on macOS or Enter on Windows and Linux. You can also right-click a schema, database or connection and choose Show Migrations (), or use .
The tab lists the migrations of one tool: those applied, in the order they were applied, then those still to come, in the order the tool would apply them. If a schema has tables of several tools, the tool's name at the top is a menu to choose another. The line beside it counts what was applied, the latest version, what is pending, what failed and what changed since it was applied.
| Status | Meaning |
|---|---|
| Applied | The tool applied it. For Alembic and golang-migrate, which record only where they stand, the ones before it count as applied too, as far as the project's files say. |
| Baseline, Schema created, Marked ran | Recorded without running a migration: Flyway's baseline and the schema it created, Liquibase's MARK_RAN and SKIPPED. |
| Failed | Recorded as failed (Flyway's success is false, Liquibase's FAILED). The tool does not go past it until it is fixed and its record repaired. |
| Dirty | golang-migrate started this version and did not finish cleanly. It refuses to run until the version is set by hand. |
| Unfinished | A Prisma migration that started and did not finish: it failed, or it is still running. |
| Rolled back, Undone, Deleted | Prisma's migrations marked rolled back, Flyway's undo and repair records. |
| Pending | In the project folder and not applied yet: the tool applies it next. |
| Outdated | A Flyway repeatable migration whose file changed: Flyway applies it again. |
| Ignored | A Flyway migration older than the newest one applied and never applied itself: Flyway does not apply it unless out-of-order migrations are allowed. |
Select a migration to see, beside the list, what was recorded about it (when, by whom, how long it took, its script and checksum), its file, whether the file changed since it was applied, what the tool recorded about a failure, and its SQL, read-only. The list moves with ↑ on macOS or Up on Windows and Linux and ↓ on macOS or Down on Windows and Linux. copies the selected migration's SQL. For more room, hide the detail with the chevron on its edge or ; the strip it leaves brings it back.
reads the history and the project folder again.
Open a pending migration in the editor
Select a Pending or Outdated migration whose SQL is shown and choose Open in Editor in the tab's toolbar (). Its SQL opens in a new query tab on the same connection and database. Nothing runs until you run it.
- What you run there is run like any other SQL: on Production Querlyn asks first, a read-only connection refuses it, and migration lock warnings apply.
- It does not update the tool's history. Querlyn does not write to
the history table, so the tool still sees the migration as pending and
will try to apply it again. The first lines of the tab say so. Use it
to try a migration on a development database, or record the migration
with the tool afterwards (Flyway's
repairorbaseline, Liquibase'schangelog-sync), as your team does. - The tab starts in the connection's usual schema. If the tool sets another schema or search path before it runs migrations, set it yourself first.
Link the project folder
Choose Link Project Folder… () in the tab and pick the folder of the project whose migrations run against this schema. The link is kept on this computer for the connection, database and schema, and is not synced: another computer has its own folders. forgets it, and shows it, or the selected migration's file, in the file manager.
Querlyn reads the folder and every folder below it and recognizes each tool's files by their names and places:
| Tool | Files |
|---|---|
| Flyway | V1_2__Description.sql, R__Description.sql and B… baseline migrations, anywhere in the folder |
| Liquibase | Changelogs in XML, YAML, JSON and formatted SQL, put in the order Liquibase meets them through include and includeAll |
| Alembic | versions/*.py: the revision and down_revision and the first line of the docstring, read as text |
| Rails | db/migrate/20261001120000_create_users.rb |
| Django | <app>/migrations/0001_initial.py, and what a squashed migration replaces |
| Prisma | prisma/migrations/<name>/migration.sql |
| golang-migrate | 000012_add_users.up.sql |
| Sqitch | sqitch.plan and the deploy scripts beside it |
| Knex | migrations/20261001120000_create_users.js (or .ts) |
| Ecto | priv/repo/migrations/20261001120000_create_posts.exs |
To stay quick and safe on any folder, Querlyn skips folders of other
people's code and build output (node_modules, vendor, deps,
site-packages, virtual environments, target, build, hidden
folders), never follows a symbolic link, reads at most 100,000 files and
folders, 12 levels deep, does not read a file larger than 32 MB, and
shows no more than 4 MB of one file's SQL. Text must be UTF-8. The tab
says what it skipped.
Migrations that are applied but whose file is not in the folder are marked no file. Django's built-in apps keep their migrations elsewhere, so their migrations are not marked.
See whether a file changed since it ran
Two tools record a checksum that Querlyn computes the same way, from the file as it is now:
- Flyway: the CRC-32 of the file's lines, ignoring line endings.
A repeatable migration that uses placeholders (
${…}) is not checked, because its checksum depends on their values. - Prisma: the SHA-256 of
migration.sql, also accepting the file with Windows line endings, as Prisma does.
A migration whose file changed is marked changed since applied, and its detail shows the checksum recorded and the file's checksum now. Flyway's validation fails on such a file until it is put back or its checksum repaired.
Liquibase and Sqitch record checksums too, but compute them in ways Querlyn does not repeat, so changed files are not flagged for them; the tab says so. The other tools record no checksum.
Check pending migrations for lock warnings
When the folder is linked and the tab's connection is open, Querlyn reads the SQL of every pending migration (Flyway, Liquibase SQL, Prisma, golang-migrate, Sqitch) with the same rules as the editor's migration lock warnings, as one script in the order the tool would run it, against the connection's server version and the tables' sizes. A pending migration that would make other sessions wait on a table that is not known to be small is marked with its warnings, for example "Rewrites “orders” and rebuilds its indexes under an ACCESS EXCLUSIVE lock … The table is 38 GB." Tables a pending migration creates count as new and empty, as they do in the editor.
Nothing is checked when lock warnings are off in Settings, or for a server Querlyn has no lock rules for; the tab says which. Migrations written in Python, Ruby, JavaScript or Elixir have no SQL to check.
Notice a failed migration or a held lock
When the sidebar lists a schema with a migration tool's table, Querlyn reads its history once for that connection, so that the Migrations row can name the tool and its latest version. If a migration failed or is dirty, or Liquibase's or Knex's lock is held, the row turns red and the status bar says so. Click the message () to open the tab, or close it with its ×; the same problem is not shown again until Querlyn quits.
This read is one small query per history table, on the connection's metadata session. It is not made for Snowflake connections, where every read runs on a warehouse you pay for: open the Migrations tab there to read the history. Every read is listed in the statement console as Migrations.
Where to go next
- Migration lock warnings: what each warning means and the safe way to make the change.
- See how a schema changed over time: snapshots of the structure itself, whatever tool changed it.
Help for Querlyn 0.1.0. All help topics