Writing migrations manually¶
Table of contents
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:
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 migration file format.
The corresponding Hasura metadata changes, if any, can be made directly in the appropriate metadata file in the
/metadata
directory, refer to metadata format.Apply the metadata and migrations:
hasura metadata apply hasura migrate apply --database <database-name> hasura metadata reload
Was this page helpful?
Thank you for your feedback!