Hasura / Postgres / Schema repository
Update the host for your Hasura Engine in config.yaml
endpoint: http://localhost:8080
To start a local server use docker-compose up -d
- Run
hasura console
at project root - Files are generated with timestamp under
./migrations
- Commit the files with git
hasura migrate create [name_of_migration]
- Paste the sql to
.up.yaml
- Make sure you append the "ON_CONFLICT" to the query
- otherwise you may need to handle the rollback situation manually (by generate delete queries)
- Commit the files with git
- Run
hasura migrate apply
- Run
hasura migrate status
to check your migration status - Use the hasura console to perform schema changes
- Before commit the schema, ensure the schema is working by rolling back it and run again
- Run
hasura migrate apply --down 1
to take down the last migration (or--down n
if you have more than 1) - Check the schema, it should be back to the original state
- If there is any errors, please check the
*.down.yaml
to fix the issues - Run
hasura migrate apply
again
- Run
- Commit the files
!! This only applies for the migration files that are not merged to staging.
- Run
hasura migrate status
to check your migration status - Run
hasura migrate apply --version 1550925483858 --type down
- where the version is the timestamp of the migration you wish to revert to
- Delete your migration files that you want to remove.
- Run
hasura migrate apply
again