2020-01-14 15:57:45 +03:00
|
|
|
.. meta::
|
|
|
|
:description: Roll back Hasura migrations
|
|
|
|
:keywords: hasura, docs, migration, roll back
|
|
|
|
|
2019-03-28 13:51:58 +03:00
|
|
|
Rolling back applied migrations
|
|
|
|
===============================
|
|
|
|
|
|
|
|
.. contents:: Table of contents
|
|
|
|
:backlinks: none
|
|
|
|
:depth: 1
|
|
|
|
:local:
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
If there are any issues with the migrations that are applied, you can
|
|
|
|
roll back the database and Hasura metadata to a desired version using the
|
2019-03-28 13:51:58 +03:00
|
|
|
``down`` migrations.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
Rollbacks will only work if there are ``down`` migrations defined. The console
|
2019-03-28 13:51:58 +03:00
|
|
|
will not generate ``down`` migrations for SQL statements executed from the
|
|
|
|
``SQL`` tab, even though you can add them as an ``up`` migration.
|
|
|
|
|
|
|
|
Rollback also means applying down migrations. Here are some example scenarios:
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
To roll back all the applied migrations, execute:
|
2019-03-28 13:51:58 +03:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2019-11-19 09:30:24 +03:00
|
|
|
hasura migrate apply --down all
|
2019-03-28 13:51:58 +03:00
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
To roll back the last 2 migration versions:
|
2019-03-28 13:51:58 +03:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
hasura migrate apply --down 2
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
To roll back a particular migration version:
|
2019-03-28 13:51:58 +03:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
hasura migrate apply --version 1550925483858 --type down
|
|
|
|
|