diff options
author | Stan Hu <stanhu@gmail.com> | 2020-04-10 02:29:45 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2020-04-11 09:26:11 +0300 |
commit | 682b1bdecd954cc3fff0fa3090e6e9620437248b (patch) | |
tree | 5e6e981b9538077ef32067841dcce7fb179a1522 /doc | |
parent | c6467d6da4e2dbe1345b7fc117dda2b816c09fc6 (diff) |
Add Praefect command to show migration status
This adds the subcommand `praefect sql-migrate-status` to show
whether a migration has been applied.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/sql_migrations.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/sql_migrations.md b/doc/sql_migrations.md index 617da054a..a20a34f20 100644 --- a/doc/sql_migrations.md +++ b/doc/sql_migrations.md @@ -12,6 +12,43 @@ Praefect SQL migrations should be applied automatically when you deploy Praefect praefect -config /path/to/config.toml sql-migrate ``` +The migration will not start if there are any migrations in the database +that are not known by the Praefect binary. + +Adding the `-ignore-unknown` will skip this check: + +```shell +praefect -config /path/to/config.toml sql-migrate -ignore-unknown +``` + +## Showing the status of migrations + +To see which migrations have been applied, run: + +``` +praefect -config /path/to/config.toml sql-migrate-status +``` + +For example, the output may look like: + +``` ++----------------------------------------+--------------------------------------+ +| MIGRATION | APPLIED | ++----------------------------------------+--------------------------------------+ +| 20200109161404_hello_world | 2020-02-26 16:00:32.486129 -0800 PST | +| 20200113151438_1_test_migration | 2020-02-26 16:00:32.486871 -0800 PST | +| 20200224220728_job_queue | 2020-03-25 16:27:21.384917 -0700 PDT | +| 20200324001604_add_sql_election_tables | no | +| 20200401010230_add_some_table | unknown migration | ++----------------------------------------+--------------------------------------+ +``` + +The first column contains the migration ID, and the second contains one of three items: + +1. The date on which the migration was applied +2. `no` if the migration has not yet been applied +3. `unknown migration` if the migration is not known by the current Praefect binary + ## Rolling back migrations Rolling back SQL migrations in Praefect works a little differently |