reset data-container
#
OverviewResetting a data container allows you to remove all changes (schema and data) made to it since the last revision. This is useful when you want to discard the last changes you have made, especially ones that would be difficult to revert otherwise (e.g. dropping a table with data).
#
Command#
ExamplesReset a data-container with id 10001
:
Reset a data-container with name dev
:
Reset multiple data-containers with ids 10001
, 10002
and 10003
:
Reset multiple data-container with names dev1
, dev2
:
#
TutorialIn this tutorial we will create a data image, then create a data container from that image. We'll then make some changes to the data container (or database) followed by a reset
operation. We will finally inspect the state of this data container.
As a prerequisite you should've followed the instructions to install spawnctl
Create a file
development.yaml
with your data image specifications.In this case we want to create a PostgreSQL data image that is completely empty and is named
dev
.Run the following command to create a data image.
You can verify your data image by running the following command.
Create a data container from the newly created data image.
You can verify your data container was properly created by running the following command.
Notice the created data container has revision
rev.0
.You should now be able to connect to your database and execute queries.
In this example we connect to the PostgreSQL data container (database) using psql.
We can now perform a reset operation on this data container.
You can now connect to this data container (database) and verify its content.
Notice that there are no relations even though we just added the table
customers
. This is because all data changes that happened after our last save are removed and the data container is restarted for the data at that checkpoint.