Skip to content

A Hasura demo using Atlas for declarative database migrations

Notifications You must be signed in to change notification settings

kevinmichaelchen/hasura-atlas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hasura-atlas

This demo shows an example Hasura project which sources its SQL migrations from Atlas, a tool used to drive declarative database migrations.

Think of it like Terraform for your database!

This is a big improvement over existing database migration solutions, for a few reasons:

  1. You can easily git diff and see how your schemas has evolved over time.
  2. You avoid accumulating dozens, if not hundreds, of up.sql migration files.

The database schema is maintained with HCL in public.hcl.

Getting started

With pkgx

Assuming you've installead pkgx, it should be easy to get started.

sudo rm -rf $(which pkgx) ; curl -fsS https://pkgx.sh | sh

Start Hasura

pkgx task start

Apply migrations

pkgx task atlas:migrate

Inspect database

pkgx task atlas:inspect

Using the API

Creating some data

mutation CreateOwnerAndPet {
  owner: insertOwnerOne(
    object: {
      name: "Kevin"
      pets: {
        data: {
          name: "Porkchop"
        }
      }
    }
  ) {
    id
    name
    pets {
      id
      name
    }
  }
}

Releases

No releases published

Packages

 
 
 

Languages