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:
- You can easily
git diff
and see how your schemas has evolved over time. - You avoid accumulating dozens, if not hundreds, of
up.sql
migration files.
The database schema is maintained with HCL in public.hcl
.
Assuming you've installead pkgx, it should be easy to get started.
sudo rm -rf $(which pkgx) ; curl -fsS https://pkgx.sh | sh
pkgx task start
pkgx task atlas:migrate
pkgx task atlas:inspect
mutation CreateOwnerAndPet {
owner: insertOwnerOne(
object: {
name: "Kevin"
pets: {
data: {
name: "Porkchop"
}
}
}
) {
id
name
pets {
id
name
}
}
}