https://github.com/kevinmichaelchen/hasura-atlas
A Hasura demo using Atlas for declarative database migrations
https://github.com/kevinmichaelchen/hasura-atlas
atlas declarative-database declarative-migrations declarative-schema hasura
Last synced: 3 months ago
JSON representation
A Hasura demo using Atlas for declarative database migrations
- Host: GitHub
- URL: https://github.com/kevinmichaelchen/hasura-atlas
- Owner: kevinmichaelchen
- Created: 2023-11-02T23:53:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-18T17:43:30.000Z (11 months ago)
- Last Synced: 2025-02-23T22:43:39.425Z (3 months ago)
- Topics: atlas, declarative-database, declarative-migrations, declarative-schema, hasura
- Language: HCL
- Homepage: https://atlasgo.io/
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hasura-atlas
This demo shows an example Hasura project which sources its SQL migrations from [Atlas][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.
1. You avoid accumulating dozens, if not hundreds, of `up.sql` migration files.The database schema is maintained with HCL in [**`public.hcl`**](./db/schema/public.hcl).
## Getting started
### With pkgx
Assuming you've installead [pkgx](https://pkgx.sh/), it should be easy to get started.
```shell
sudo rm -rf $(which pkgx) ; curl -fsS https://pkgx.sh | sh
```#### Start Hasura
```shell
pkgx task start
```#### Apply migrations
```shell
pkgx task atlas:migrate
```#### Inspect database
```shell
pkgx task atlas:inspect
```## Using the API
### Creating some data
```graphql
mutation CreateOwnerAndPet {
owner: insertOwnerOne(
object: {
name: "Kevin"
pets: {
data: {
name: "Porkchop"
}
}
}
) {
id
name
pets {
id
name
}
}
}
```[atlas]: https://atlasgo.io/