hasura / hasura/graphql-engine
Cannot create an event due to a hdb_catalog migration error
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: v2.31.0
### Environment
OSS
### What is the current behaviour?
Creating an even trigger fails while trying to migrate the db it seems.
### What is the expected behaviour?
The event trigger gets created with no problems.
### How to reproduce the issue?
1. Attempt to create an event
2. Fail
### Screenshots or Screencast

### Please provide any traces or logs that could help here.
```
[
{
"definition": {
"configuration": {
"definition": {
"enable_manual": false,
"insert": {
"columns": "*"
},
"update": {
"columns": "*"
}
},
"headers": [],
"name": "super_fund_control_trigger",
"retry_conf": {
"interval_sec": 10,
"num_retries": 0,
"timeout_sec": 60
},
"webhook": "https://dev-api.imktbi.com/dadmin/reconciliation/fund/trigger"
},
"table": {
"name": "super_fund",
"schema": "public"
}
},
"message": {
"arguments": [],
"error": {
"description": null,
"exec_status": "FatalError",
"hint": null,
"message": "invalid input syntax for type timestamp with time zone: \"t\"",
"status_code": "22007"
},
"prepared": false,
"statement": "ALTER TABLE hdb_catalog.event_log\nALTER COLUMN id\nSET DEFAULT hdb_catalog.gen_hasura_uuid();\n\nALTER TABLE hdb_catalog.event_invocation_logs\nALTER COLUMN id\nSET DEFAULT hdb_catalog.gen_hasura_uuid();\n\nALTER TABLE hdb_catalog.event_log RENAME COLUMN locked TO locked_boolean;\n\nALTER TABLE hdb_catalog.event_log ADD COLUMN locked TIMESTAMPTZ;\n\nUPDATE hdb_catalog.event_log\nSET locked = NOW()\nWHERE locked_boolean = 't';\n\nALTER TABLE hdb_catalog.event_log DROP COLUMN locked_boolean;\n"
},
"name": "event_trigger super_fund_control_trigger in table super_fund in source default",
"reason": "Inconsistent object: database query error",
"type": "event_trigger"
}
]
```
Here is the table itself

### Any possible solutions/workarounds you're aware of?
Looking at the offending code from the error message:
```
ALTER TABLE hdb_catalog.event_log
ALTER COLUMN id SET DEFAULT hdb_catalog.gen_hasura_uuid();
ALTER TABLE hdb_catalog.event_invocation_logs
ALTER COLUMN id SET DEFAULT hdb_catalog.gen_hasura_uuid();
ALTER TABLE hdb_catalog.event_log
RENAME COLUMN locked TO locked_boolean;
ALTER TABLE hdb_catalog.event_log
ADD COLUMN locked TIMESTAMPTZ;
UPDATE hdb_catalog.event_log
SET locked = NOW()
WHERE locked_boolean = 't';
ALTER TABLE hdb_catalog.event_log
DROP COLUMN locked_boolean;
```
Column `locked` of the `hdb_catalog.event_log` is already timestampz ( https://github.com/hasura/graphql-engine/blob/3ec1e5e2da4c86e4c2647d7d0f9123ce2e3f9b27/server/src-rsr/pg_source_migrations/0_to_1.sql#L11 )
The code above assumes it is boolean it seems.
It looks like a migration is applied when it should not be applied? Am I missing something?
Contributor guide
Assessment
This issue has not been assessed yet.