graphql-engine/docs/graphql/core/migrations/advanced/writing-migrations-manually.rst
Praveen Durairaju 3ad42ed540 docs: add webinar links
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: d5b680ce50bfa331bbead32ffe8ad7ba95a6b51f
2021-03-09 08:37:34 +00:00

53 lines
1.6 KiB
ReStructuredText

.. meta::
:description: Write manual migrations for Hasura GraphQL engine
:keywords: hasura, docs, migration, manual
.. _manual_migrations:
Writing migrations manually
===========================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
Introduction
------------
While the Hasura console can auto generate migrations for every action,
sometimes you might want to write the migrations yourself, by hand. Using the
Hasura CLI, you can bootstrap these migration files and write the SQL for the
Postgres schema.
Create migration manually
-------------------------
#. Set up the migration files:
.. code-block:: bash
hasura migrate create <name-of-migration> --database <database-name>
This command will create up and down migration SQL files in the
``migrations`` directory.
#. Edit the file and add your migration actions. For the file format and
instructions on what actions can be added, refer to
:ref:`migration file format <migration_file_format_v2>`.
#. The corresponding Hasura metadata changes, if any, can be made directly in
the appropriate metadata file in the ``/metadata`` directory, refer to
:ref:`metadata format <metadata_format_v2>`.
#. Apply the metadata and migrations:
.. code-block:: bash
hasura metadata apply
hasura migrate apply --database <database-name>
hasura metadata reload
.. admonition:: Additional Resources
Hasura Database Schema Migrations - `Watch Webinar <https://hasura.io/events/webinar/hasura-database-schema-migrations/?pg=docs&plcmt=body&cta=watch-webinar&tech=>`__.