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. Peep sqitchchanges to 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 be name=value, like --set defuser='Homer Simpson'. This overrides any values loaded from configuration 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 to 60. ⏳
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:

These can be overridden by --set or by target and engine configuration. Variables get merged in this priority order, bestie πŸ‘‡

  1. --set
  2. target.$target.variables
  3. engine.$engine.variables
  4. revert.variables
  5. deploy.variables
  6. core.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 to true, 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