graphql-engine/docs/graphql/manual/migrations/reference/migration-file-format.rst
2020-04-29 13:30:26 +05:30

46 lines
1.2 KiB
ReStructuredText

.. meta::
:description: Hasura Migration file format reference
:keywords: hasura, docs, migration, file format
.. _migration_file_format_v2:
Migration file format reference
===============================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
Introduction
------------
With ``config v2``, the migrations files are pure SQL files.
.. note::
For ``config v1``, see :ref:`migration_file_format_v1`.
Migration filename format
-------------------------
Each migration file has the following format:
.. code-block:: bash
<version>_<name>.{up|down}.sql
A ``version`` which is the Unix timestamp in nanoseconds when the file was
created is the first part. Followed by a ``name`` which is either manually added
or auto-generated by the console. The next part indicates what step this is. If
it is ``up``, it means that this is the forward step, e.g. creating a table.
The ``down`` indicates that it is the corresponding
rollback step.
Migration file format
---------------------
A migration SQL file can contain SQL statements which are executed
on the apply step of the migration. There can be an ``up`` migration and a ``down``
migration file.