hasura / hasura/graphql-engine

renaming a table with incoming FK relationships fails without error feedback

Open
#3,627 4 comments 0 reactions 1 assignee Claimed by @0x777 View on GitHub
c/server support/needs-more-info
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

# summary

When trying to rename a table, `userGoal` -> `userHabit`, that has incoming relationships, eg. `metric.userGoalId -> userGoal.id`, the api call to `migrate` fails but no error message is displayed.

# repro

1. create 2 tables, one with an object relation to the other.
2. rename the table with the incoming table (the one with the primary key as part of the relation)

expect: rename is successful or fails with red toast error message
actual: rename in progress toast disappears with no further feedback

# errors

## api call to `migrate`

```
{"code":"internal_error","message":"json: cannot unmarshal array into Go struct field HasuraError.internal of type hasuradb.SQLInternalError"}
```

## server log message

```
hasura_1 | {"type":"http-log","timestamp":"2020-01-03T02:47:59.873+0000","level":"error","detail":{"operation":{"user_vars":{"x-hasura-role":"admin"},"error":{"internal":[{"definition":{"using":{"manual_configuration":{"remote_table":"userGoal","column_mapping":{"id":"userHabitId"}}},"name":"metrics","comment":null,"table":"userHabit"},"reason":"table \"userGoal\" does not exist","type":"array_relation"}],"path":"$.args[0].args","error":"cannot continue due to newly found inconsistent metadata","code":"unexpected"},"request_id":"285a4268-f49e-454c-af35-1ac4985f6959","response_size":362,"query":{"args":[{"args":{"cascade":false,"check_metadata_consistency":null,"sql":"alter table \"public\".\"userGoal\" rename to \"userHabit\";","read_only":false},"version":1,"type":"run_sql"},{"args":{"cascade":false,"check_metadata_consistency":null,"sql":"INSERT INTO hdb_catalog.schema_migrations (version, dirty) VALUES (1578019679817, false)","read_only":false},"version":1,"type":"run_sql"}],"version":1,"type":"bulk"}},"http_info":{"status":500,"http_version":"HTTP/1.1","url":"/v1/query","ip":"172.20.0.1","method":"POST","content_encoding":null}}}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.