hasura / hasura/graphql-engine
CLI: hasura migrate status fails when no hdb_catalog exists on a config v2 project
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.10.1
CLI Version (for CLI related issue): 2.10.1
### Environment
OSS
### What is the current behaviour?
When running `hasura migrate status` from a config v2 directory, hasura attempts to create the `hdb_catalog.schema_migrations` table if it does not exist.
This fails if the `hdb_catalog` schema does not exist.
This issue may affect all `hasura migrate` commands.
### What is the expected behaviour?
The `hdb_catalog` schema should be created when required if it does not exist.
### How to reproduce the issue?
1. Bring up a config v2 compatible HGE instance with a separate metadata db and user db
sample docker-compose.yaml
```yaml
version: "3.8"
services:
postgres:
image: postgres:14
expose:
- 5432
volumes:
- postgres-data:/var/lib/postgresql/data
- ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_USER: ${POSTGRES_USERNAME:-postgres}
POSTGRES_DB: metadata
graphql-engine:
restart: always
image: hasura/graphql-engine:v2.10.1
ports:
- "8080:8080"
depends_on:
- postgres
environment:
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://${POSTGRES_USERNAME:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/metadata
HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USERNAME:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
```
2. Create a config v2 metadata and migrations directory
```sh
hasura init --version 2
```
3. Attempt to read the migration state
```sh
hasura migrate status
```
4. An error is thrown because the `hdb_catalog` schema does not exist in the `postgres` database
### Any possible solutions?
Users can easily work around this by creating the `hdb_catalog` schema in their user database:
```sql
CREATE SCHEMA hdb_catalog;
```
However, we'd strongly encourage users to [migrate to config v3](https://hasura.io/docs/latest/migrations-metadata-seeds/legacy-configs/upgrade-v3/) instead.
Contributor guide
Assessment
This issue has not been assessed yet.