The Migration file format

These are the principles:

  1. In short, migration files are pure SQL files.

  2. Each migration file has the following format:

    <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.

  3. A migration SQL file can contain SQL statements which are executed on the apply step of the migration.

  4. The UP file contains any sql statements to be run by the apply command, you can think of this as going UP one version. The SQL can create, update, drop tables, rename resources, etc. Whatever is necessary to accomplish the NEXT version.

  5. The DOWN file contains any SQL statements to roll back this version. It is a bit more complex because it has to change back any modifications made by UP.

For more details on the format of these files, refer to the Migration file format documentation

Hasura Migrations - The Metadata directory

The following files will be generated in the metadata/ directory of your project.

  • version.yaml: Contains the metadata version of the server

  • tables.yaml: Contains the metadata related to tables

  • remote_schemas.yaml: Contains the metadata related to remote schemas

  • functions.yaml: Contains the metadata related to custom functions

  • allow_list.yaml: Contains the metadata related to allow lists

  • actions.yaml: Contains the metadata related to actions

  • actions.graphql: Contains all the action definition and custom type definitions

For more details on the format of these files, refer to the Metadata directory format documentation

Last updated