Hasura is a graphql engine which makes it easy to create CRUD graphql on top of postgres aside from stitching together APIs providing and eventing queue!
About KintoHub:
KintoHub aligns teams to ship & operate cloud native apps with ease. Learn More
- Apply this template to your Github
- Create a Website Block on KintoHub:
- Set the name of your block
- Select
Dynamic Web App
- For
language
selectCustom Dockerfile
- Set the port to 8080
- Hit the
Create
button - You're now good to build! Click
Build Latest Commit
. Once complete, Click Now clickAdd To Project
and Create a new Project. - Scroll to "KintoBlocks" section and in the Search Box type "Postgres" and select it to add a Postgres Database.
- Click
Create New Project
at bottom right
The deployment can take up to 3 minutes. Once successful, click Open URL
on the Hasura Block under "KintoBlocks" section.
Run docker-compose up -d
Click "Open URL" and start playing with hasura. We recommend using the advance migration functionality for multiple environments such as dev
and staging
.
- Password protect your hasura instance
- Setup
dev
andstaging
environments - Read KintoHub's block series on Hasura
Hasura console records every schema changes and generate the migration queries as file. In this project,we have set it up to automatically update your database when being deployed on KintoHub and be able to easily run it locally on your machine to test. Migrations are branch friendly :)
You have the following files:
- config.yaml to configure your hasura cli tools
- docker-compose used to configure local postgres database and hasura instance for local testing and creating migrations.
- Dockerfile is used to build and deploy your migrations onto Kintohub.
- migrations folder has all changesets / migrations in it currently empty by default.
Install hasura cli tools here
To start a local server use docker-compose up -d
NOTE: If you changed your port in the docker-compose
file, make sure to update/syc the config.yaml
entrypoint.
- 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 your files
- 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
- 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
In case you need to setup the database from scratch:
- Ensure you have a super admin account or check to ensure you have these permissions setup
- Install the hasura cli tools
- Configure the
config.yaml
- Ensure hasura working properly by running
hasura console
- Run
hasura migrate apply
to run the migration