You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.**Update metadata** to reflect schema changes in Hasura:
54
+
55
+
```bash
56
+
hasura metadata apply
57
+
```
58
+
59
+
4.**Reload metadata** if you need to refresh the GraphQL schema:
60
+
```bash
61
+
hasura metadata reload
62
+
```
63
+
64
+
### Troubleshooting Common Issues
65
+
66
+
#### "Field not found in type" Error
67
+
68
+
**Problem**: You get an error like `field 'dataset_id' not found in type: 'thread'` even though the column exists in the database.
69
+
70
+
**Cause**: The database schema has been updated (via migrations), but the Hasura metadata hasn't been updated to reflect the new column in the GraphQL schema.
71
+
72
+
**Solution**:
73
+
74
+
1.**Check if the column exists in the database**:
75
+
76
+
```sql
77
+
\d thread; -- PostgreSQL command to describe table
78
+
```
79
+
80
+
2.**Verify the migration was applied**:
81
+
82
+
```bash
83
+
hasura migrate status
84
+
```
85
+
86
+
3.**Check if the column is included in metadata**:
87
+
Look in `metadata/tables.yaml` for the table definition and ensure the column is listed in:
88
+
89
+
-`insert_permissions.columns`
90
+
-`select_permissions.columns`
91
+
-`update_permissions.columns`
92
+
93
+
4.**Apply metadata changes**:
94
+
95
+
```bash
96
+
hasura metadata apply
97
+
```
98
+
99
+
5.**Reload metadata if needed**:
100
+
101
+
```bash
102
+
hasura metadata reload
103
+
```
104
+
105
+
6.**Restart Hasura service** (if running in Kubernetes):
106
+
```bash
107
+
kubectl rollout restart deployment/mint-hasura
108
+
```
109
+
110
+
#### Metadata vs Database Schema Mismatch
111
+
112
+
**Problem**: Database schema and Hasura metadata are out of sync.
113
+
114
+
**Solution**:
115
+
116
+
1.**Export current metadata** to see what Hasura thinks the schema is:
117
+
118
+
```bash
119
+
hasura metadata export
120
+
```
121
+
122
+
2.**Compare with your local metadata files** to identify discrepancies.
123
+
124
+
3.**Apply your local metadata**:
125
+
126
+
```bash
127
+
hasura metadata apply
128
+
```
129
+
130
+
4.**If conflicts exist**, you may need to:
131
+
- Reset metadata: `hasura metadata reset`
132
+
- Re-apply your metadata: `hasura metadata apply`
133
+
134
+
### Important Notes
135
+
136
+
-**Always apply migrations before metadata**: Database schema changes must be applied before updating Hasura metadata
137
+
-**Metadata is the source of truth**: Hasura's GraphQL schema is generated from metadata, not directly from the database
138
+
-**Column permissions**: New columns must be explicitly added to permission configurations in metadata
139
+
-**Kubernetes deployments**: After metadata changes, you may need to restart the Hasura pod for changes to take effect
140
+
141
+
### File Structure
142
+
143
+
```
144
+
graphql_engine/
145
+
├── migrations/ # Database schema migrations
146
+
│ ├── 1662641297914_init/
147
+
│ ├── 1751375338869_add_dataset_id_subtask/
148
+
│ └── ...
149
+
├── metadata/ # Hasura metadata configuration
150
+
│ ├── tables.yaml # Table definitions and permissions
151
+
│ ├── actions.yaml # Custom actions
152
+
│ └── ...
153
+
├── seeds/ # Initial data population
154
+
└── config.yaml # Hasura configuration
155
+
```
156
+
157
+
### Best Practices
158
+
159
+
1.**Version control**: Always commit both migrations and metadata changes together
160
+
2.**Testing**: Test migrations and metadata changes in a development environment first
161
+
3.**Backup**: Create database backups before applying migrations in production
162
+
4.**Documentation**: Document schema changes and their purpose
163
+
5.**Rollback plan**: Ensure migrations can be rolled back if needed
0 commit comments