fix: correct NocoDB column creation endpoint and add startup delay
All checks were successful
Deploy HiHala Dashboard / deploy (push) Successful in 9s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
fahed
2026-04-08 18:14:56 +03:00
parent e09c3f8190
commit 35771595dc
2 changed files with 17 additions and 13 deletions

View File

@@ -34,6 +34,8 @@ app.listen(server.port, () => {
console.log(' NocoDB: configured');
console.log(' POST /api/etl/sync?mode=full|incremental');
// Ensure Users table has permission fields
// Delay slightly to ensure NocoDB is fully ready before migrating
setTimeout(() => {
discoverTableIds().then(tables => {
if (tables['Users']) {
return ensureTableFields(tables['Users'], [
@@ -42,6 +44,7 @@ app.listen(server.port, () => {
]);
}
}).catch(err => console.warn(' NocoDB migration warning:', err.message));
}, 3000);
} else {
console.log(' NocoDB: WARNING — not configured');
}

View File

@@ -126,13 +126,14 @@ export async function fetchAllRecords<T>(tableId: string): Promise<T[]> {
}
export async function ensureTableFields(tableId: string, fields: Array<{ title: string; uidt: string }>): Promise<void> {
const json = await fetchJson(
`${nocodb.url}/api/v2/tables/${tableId}/fields`
) as { list: Array<{ title: string }> };
const existing = new Set(json.list.map(f => f.title));
// GET /api/v2/meta/tables/{id} returns table with columns array
const table = await fetchJson(
`${nocodb.url}/api/v2/meta/tables/${tableId}`
) as { columns: Array<{ title: string }> };
const existing = new Set((table.columns || []).map(f => f.title));
for (const field of fields) {
if (!existing.has(field.title)) {
await fetchJson(`${nocodb.url}/api/v2/tables/${tableId}/fields`, {
await fetchJson(`${nocodb.url}/api/v2/meta/tables/${tableId}/columns`, {
method: 'POST',
body: JSON.stringify(field),
});