It’s fine, Rewind: Revert a migration without losing data

It’s fine, Rewind: Revert a migration without losing data

Taylor Barnett
Taylor Barnett
3/24/20224 min read

Bad migrations happen every day and data loss can be devastating. PlanetScale’s new Rewind feature gives you the power to revert changes after a schema migration with no downtime and zero data loss.

What is Rewind?

Have you ever made a schema change, like changing a column’s data type or dropping a table, that broke your production application causing unplanned downtime, or even worse, a full-scale outage? And once it was live, you immediately wished you could go back in time, without losing any data that was added during the broken period?

Your wish has come true. PlanetScale’s new Rewind feature allows you to revert a migration with zero data loss.

Rewind enables something never possible before: The ability to revert your database’s schema changes in less than a minute with the press of a button with no downtime or data loss. Previously, if you dropped the wrong index, running a new migration might take you a few hours to fix. Even worse, if you dropped the wrong column or table and had to restore from a backup, it would take days or weeks to roll out. And what happens to your data and your application while it is being fixed? With Rewind, you don’t need to worry about downtime or data loss.

Rewind opens the door to a new level of velocity and power for your engineering team. Along with existing PlanetScale features such as Database Branching™ and Deploy Requests, you can make changes (and fix changes) in your database faster and safer than before. It not only saves you time, but it makes schema changes less scary because you can treat your database like you treat your code. Unless you built custom in-house tooling for your database, these workflows have not been possible before.

We are giving away limited-edition, retro Rewind t-shirts to the first 100 people that successfully revert a schema change or share about a time that Rewind would have helped you.

All you have to do is:

  • Deploy a schema change
  • Revert it in seconds
  • Take a screenshot/video
  • Share on Twitter and tag @planetscaledata

Or:

  • Share on Twitter about a time that Rewind would have helped you revert a schema change in production and tag @planetscaledata

This giveaway is US only while supplies last. Void where prohibited; one per household.

How does it work?

After you have completed a deploy request, you will be able to revert to a clean state of the database before the schema changes. This includes any data that may have been removed in the deploy request. Any database enrolled in the limited beta will see a “Revert changes” button available on the relevant deploy request page for 30 minutes after the changes have been deployed. Once the “Revert changes” button is selected, it is deployed immediately.

For example, if you remove a column and its associated data in a deploy request then revert with Rewind, your column and its associated data will appear again in seconds.

Rewind is possible because of VReplication in Vitess, the database clustering and management system that powers PlanetScale databases alongside MySQL. Vitess’ VReplication also powers features like Database Imports. VReplication uses a lossless sync in the background between valid states of the database. It copies data from the source to the destination table in a consistent fashion. VReplication’s implementation is unique because it allows us to go down to the MySQL transaction level, ensuring no data is lost and that your database schema returns to its previous state before the schema change. All in just seconds.

For a more in-depth look at how Rewind works, take a look at the Behind the scenes: how we built Rewind blog post.

Want to see it in action?

Sign up for the limited beta to test it out yourself! Sign up or log into PlanetScale and opt into the limited beta in your database's Settings tab. In the Beta features section, select “Enroll this database in the Rewind limited beta.” Once you create a database branch with changes to your schema, deploy the deploy request, and then Rewind!

For more information, check out our Deploy requests – Revert a schema change documentation.

We can’t wait to hear what you think about Rewind!

Limited edition, Rewind t-shirt giveaway

We are giving away limited-edition, retro Rewind t-shirts to the first 100 people that successfully revert a schema change or share about a time that Rewind would have helped you.

All you have to do is:

  • Deploy a schema change
  • Revert it in seconds
  • Take a screenshot/video
  • Share on Twitter and tag @planetscaledata

Or:

  • Share on Twitter about a time that Rewind would have helped you revert a schema change in production and tag @planetscaledata

This giveaway is US only while supplies last. Void where prohibited; one per household.

The last database you’ll ever need
Start your database in seconds