Migration file format reference (config v1)
Migration filename format
Each migration file has the following format:
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, for
e.g. creating a relationship or a table. The
down indicates that it is
the corresponding rollback step. The last part denotes the file format -
whether it is an SQL file or a YAML file.
down YAML file contains Hasura metadata API actions to be
executed for that particular migration. The file should have a list of
such API actions, which is represented with a
- in YAML. Here is an
- type: run_sql
CREATE TABLE "public"."author" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
PRIMARY KEY ("id")
- type: track_table
- type: untrack_table
- type: run_sql
DROP TABLE "public"."author"
Each one of the actions in these files are actually Hasura metadata API calls, which are executed in sequence when the migration is applied. You can find all the metadata actions that are available in the metadata API reference.
The files are there just for the user's convenience, since the SQL can already be included in the YAML files.
As the name indicates, an SQL file can contain SQL statements which are
executed on the apply step of the migration. There can be an
down SQL file. The SQL file is executed first if it is present
in an up migration and the YAML file is executed first in a down