mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-11 10:46:25 +03:00
docs: update cli migrations page
[DOCS-1094]: https://hasurahq.atlassian.net/browse/DOCS-1094?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10434 GitOrigin-RevId: ce6432073dd686a83a26b96d58f69553cac61c33
This commit is contained in:
parent
a722d258c5
commit
120a9470ee
@ -17,6 +17,14 @@ keywords:
|
||||
Hasura ships a special `cli-migrations` Docker image which can be used to automatically apply Migrations and Metadata
|
||||
when the server starts.
|
||||
|
||||
### What does it mean to "auto-apply" Migrations and Metadata?
|
||||
|
||||
Auto-applying migrations means that Hasura can automatically apply database schema changes or migrations to your
|
||||
underlying database without requiring manual intervention. This feature simplifies the process of keeping your database
|
||||
schema in sync with your GraphQL schema and makes it easier to evolve your application over time.
|
||||
|
||||
### How does it work?
|
||||
|
||||
This image is a drop-in place replacement for the standard Hasura GraphQL Engine
|
||||
[images](https://hub.docker.com/r/hasura/graphql-engine). This container provides a method to apply
|
||||
[Migrations and Metadata](/migrations-metadata-seeds/overview.mdx) automatically when the container starts up. It works
|
||||
@ -65,9 +73,10 @@ For `config v2`, see
|
||||
## Applying Migrations
|
||||
|
||||
The `migrations` and `metadata` directories created by the Hasura CLI in a Hasura Project can be mounted at the
|
||||
`/hasura-migrations` and `/hasura-metadata` paths of this Docker container and the container's entrypoint script will
|
||||
automatically apply the Migrations and Metadata before starting the server. If no directory is mounted at the designated
|
||||
paths, the server will start and ignore the Migrations and/or Metadata.
|
||||
`/hasura-migrations` and `/hasura-metadata`
|
||||
[paths of this Docker container and the container's entrypoint script](https://github.com/hasura/graphql-engine/blob/master/packaging/cli-migrations/v3/docker-entrypoint.sh#L12C1-L13)
|
||||
will automatically apply the Migrations and Metadata before starting the server. If no directory is mounted at the
|
||||
designated paths, the server will start and ignore the Migrations and/or Metadata.
|
||||
|
||||
You can also mount the Migrations/Metadata directories at some location other than the above by setting the following
|
||||
environment variables:
|
||||
@ -93,5 +102,6 @@ docker run -p 8080:8080 \
|
||||
## Applying only Metadata {#auto-apply-metadata}
|
||||
|
||||
If you're managing Migrations with a different tool and want to use this image to apply only the metadata, mount the
|
||||
`metadata` directory of your Hasura Project at the `/hasura-metadata` path of this Docker container the container’s
|
||||
entry point script will apply the Metadata before starting the server.
|
||||
`metadata` directory of your Hasura Project at the `/hasura-metadata`
|
||||
[path of this Docker container the container's entry point script](https://github.com/hasura/graphql-engine/blob/master/packaging/cli-migrations/v3/docker-entrypoint.sh#L13)
|
||||
will apply the Metadata before starting the server.
|
||||
|
@ -1,17 +1,14 @@
|
||||
# CLI Migrations
|
||||
|
||||
This docker image provides a method to run migrations and metadata at docker entrypoint.
|
||||
A temporary server is booted, with the migrations API allowed, securely through localhost.
|
||||
Once migrations and metadata have been applied, the server will reboot in a secure mode for inbound graphql usage.
|
||||
This docker image provides a method to run migrations and metadata at docker entrypoint. A temporary server is booted,
|
||||
with the migrations API allowed, securely through localhost. Once migrations and metadata have been applied, the server
|
||||
will reboot in a secure mode for inbound graphql usage.
|
||||
|
||||
See [./docker-entrypoint.sh](docker-entrypoint.sh)
|
||||
|
||||
- [CLI Migrations](#cli-migrations)
|
||||
- [Examples](#examples)
|
||||
- [Local](#local)
|
||||
- [Heroku](#heroku)
|
||||
- [Provision](#provision)
|
||||
- [Deploy](#deploy)
|
||||
- [Configuration](#configuration)
|
||||
- [Migrations Directory (Optional)](#migrations-directory-optional)
|
||||
- [Metadata Directory (Optional)](#metadata-directory-optional)
|
||||
@ -34,44 +31,9 @@ CMD graphql-engine \
|
||||
|
||||
### Local
|
||||
|
||||
This is covered in the documentation here: https://hasura.io/docs/latest/graphql/core/migrations/auto-apply-migrations.html
|
||||
The below [Configuration](#configuration) will also be applicable.
|
||||
|
||||
### Heroku
|
||||
|
||||
Using a docker build on heroku the manifest (`heroku.yml`) can look like:
|
||||
|
||||
```yaml
|
||||
setup:
|
||||
addons:
|
||||
- plan: heroku-postgresql
|
||||
as: DATABASE
|
||||
config:
|
||||
HASURA_METADATA_DATABASE_URL: DATABASE_URL
|
||||
build:
|
||||
docker:
|
||||
web: Dockerfile
|
||||
```
|
||||
|
||||
This allows you to provision and migrate a database entirely without intervention.
|
||||
|
||||
#### Provision
|
||||
|
||||
Setup the app, with addons and the setup steps defined in the heroku.yml
|
||||
|
||||
```bash
|
||||
heroku create heroku-migration-tester --manifest
|
||||
```
|
||||
|
||||
#### Deploy
|
||||
|
||||
```bash
|
||||
export HEROKU_GIT_REMOTE=https://git.heroku.com/heroku-migration-tester.git
|
||||
git init && git add .
|
||||
git commit -m "first commit"
|
||||
git remote add heroku HEROKU_GIT_REMOTE
|
||||
git push heroku master
|
||||
```
|
||||
This is covered in the documentation here:
|
||||
https://hasura.io/docs/latest/graphql/core/migrations/auto-apply-migrations.html The below
|
||||
[Configuration](#configuration) will also be applicable.
|
||||
|
||||
## Configuration
|
||||
|
||||
@ -99,12 +61,12 @@ If it has been stored in a directory other than the default then it can be confi
|
||||
|
||||
### GraphQL Server (Optional)
|
||||
|
||||
Optional configuration for the server which boots during migrations.
|
||||
Optional configuration for the server which boots during migrations.
|
||||
|
||||
- `HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT` (default=`9691`)
|
||||
|
||||
Specify the port running the graphql server during execution of the migration script.
|
||||
It is advised that you do not specify a PORT that may be open e.g. 80/443 and the default should rarely require changing.
|
||||
Specify the port running the graphql server during execution of the migration script. It is advised that you do not
|
||||
specify a PORT that may be open e.g. 80/443 and the default should rarely require changing.
|
||||
|
||||
- `HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT` (default=`30s`)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user