sqitch-revert(3pm)
okay bestie, pull up a chair π this is the sqitch-revert(3pm) manual page from the User Contributed Perl Documentation, and no cap, it's about to explain how to do actual time travel on your database. let's get into it π¦
πΈ NAME πΈ
sqitch-revert β revert changes to a database π«
β¨ SYNOPSIS β¨
sqitch revert [options] [<database>]
sqitch revert [options] [<database>] <change>
sqitch revert [options] [<database>] --to-change <change>
sqitch revert [options] [<database>] --modified
π DESCRIPTION π
So here's the tea, bestie π«: sqitch revert undoes changes on your database. It starts from wherever you're currently deployed and walks backwards, reverting changes in reverse the order they were applied. By default it reverts all the changes β unless you name a target change, either through --to or just by passing it along with no option flag, in which case it reverts back to that change.
If the database was never deployed to, or its state already matches the change you specified, then nothing happens. Zero. Nada. π But if the change you named shows up later in the plan than what's currently deployed, you get an error β plus a little suggestion telling you to use sqitch-deploy instead. it's giving "wrong direction, girlie."
The <database> parameter is the database you want to connect to, and you can also hand it over as the --target option instead. It can be a target name, a URI, an engine name, or a plan file path β¨
π Attention Git Users π
If you're a git user sitting there thinking this works like git revert β it does not, bestie, sorry π
sqitch revert is way more like time travel. It takes your database all the way back to the state it was in right after the target change got applied. It absolutely feels like magic π§ but it's actually just all that time you spent writing revert scripts finally paying off. Starting from the last change that's currently deployed, sqitch revert runs each revert script in turn until it reaches the target change β and that target change becomes the last change deployed. periodt. π
π OPTIONS π
-t,--targetβ The target database you want to connect to. This can be either a URI or the name of a target in the configuration. π―--to-change,--change,--toβ Name the reversion change. Defaults to reverting all the changes. Peepsqitchchangesto see all the ways you can spell out a change. π-m,--modifiedβ Figures out the change to revert onto based on modifications to your deploy scripts. It reverts the change prior to the earliest change that has a revised deploy script. π-s,--setβ Set a variable name and value for the database engine client to use, if that client supports variables. The format has to bename=value, like--set defuser='Homer Simpson'. This overrides any values loaded fromconfiguration Variables. πΈ--log-onlyβ Logs the changes as if they were reverted, but without actually running the revert scripts. Fake it till you make it, but make it log. π--lock-timeoutβ Set the number of seconds Sqitch waits to grab an exclusive advisory lock on the target database, for engines that support that kind of lock. This lock stops other Sqitch instances from deploying to the same target at the same time, but it blocks no other database activity. Defaults to60. β³
sqitch deploy --lock-timeout 600
-yβ Disables the prompt that normally asks whether or not to actually execute the revert. No more "are you sure?" energy. π--registryβ The name of the Sqitch registry schema or database β the place where sqitch stores its own data. ποΈ
sqitch revert --registry registry
--db-client,--clientβ Path to the command-line client for the database engine. Defaults to a client in the current path named appropriately for the database engine. π₯οΈ
sqitch revert --client /usr/local/pgsql/bin/psql
-d,--db-nameβ Name of the database. Generally speaking, targets and URIs are the preferred vibe, but you can use this option to override the database name inside a target. π
sqitch revert --db-name widgets
sqitch revert -d bricolage
-u,--db-user,--db-usernameβ User name to use when connecting to the database. Heads up: this does not apply to all engines. Targets and URIs are generally preferred, but this option can override the user name in a target. π«Ά
sqitch revert --db-username root
sqitch revert --db-user postgres
sqitch revert -u Mom
-h,--db-hostβ Host name to use when connecting to the database. Also does not apply to all engines. Targets and URIs are preferred in general, but this can override the host name in a target. π
sqitch revert --db-host db.example.com
sqitch revert -h appdb.example.net
-p,--db-portβ Port number to connect to. Yep, this one also doesn't apply to all engines. Targets and URIs are the general fave, but this option can override the port in a target. π
sqitch revert --db-port 7654
sqitch revert -p 5431
--plan-file,-fβ Path to the deployment plan file. This overrides target, engine, and core configuration values. Defaults to$top_dir/sqitch.plan. π
sqitch revert --plan-file my.plan
π CONFIGURATION VARIABLES π
[deploy.variables][revert.variables]
A section that defines database client variables. The deploy.variables configuration gets read from the deploy command configuration β on the assumption that the values are generally gonna be the same when you revert. If they're not, use revert.variables to override deploy.variables. π
These variables are super useful if your database engine supports variables in scripts, like:
- PostgreSQL's
psqlvariables βhttps://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-INTERPOLATION - Vertica's
vsqlvariables βhttps://docs.vertica.com/24.2.x/en/connecting-to/using-vsql/variables/ - MySQL's user variables β
https://dev.mysql.com/doc/refman/5.6/en/user-variables.html - SQL*Plus's
DEFINEvariables βhttps://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12017.htm - Snowflake's SnowSQL variables β
https://docs.snowflake.com/en/user-guide/snowsql-use.html#using-variables - ClickHouse's queries with parameters β
https://clickhouse.com/docs/interfaces/cli#cli-queries-with-parameters
These can be overridden by --set or by target and engine configuration. Variables get merged in this priority order, bestie π
--settarget.$target.variablesengine.$engine.variablesrevert.variablesdeploy.variablescore.variables
revert.strictβ A boolean value saying whether or not the change you revert to must be specified. π¨revert.no_promptβ A boolean value saying whether or not to disable the prompt before executing the revert. Can be overridden by-y. π€«revert.prompt_acceptβ A boolean value saying whether the default reply to the prompt before executing the revert should be "yes" or "no". Defaults totrue, meaning it'll accept the revert. β
π SQITCH π
Part of the sqitch suite. you already knew that though. π
and that's the whole page, bestie β go forth and rewind your database with main character energy π this lil' rewrite is living in perl v5.40.1 world, dated 2026-07-26, and that's on sqitch-revert(3pm). mwah πβ¨
π¦ where this page comes from
- ubuntu stonking: sqitch 1.6.1-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms